Logging in Simantics Platform

From Developer Documents
Revision as of 13:40, 23 September 2016 by Jani Simomaa (talk | contribs)
Jump to navigation Jump to search

For uniform logging in Simantics Platform The Simple Logging Facade for Java (org.slf4j.api) and Logback Project (ch.qos.logback.classic) is included in Simantics SDK. To use the SLF4J logging API just include the following bundle in your own plugin's MANIFEST.MF dependencies:

Require-Bundle: ..,
org.slf4j.api

An example usage of logging inside your own java code is presented below:

 1: import org.slf4j.Logger;
 2: import org.slf4j.LoggerFactory;
 3: 
 4: public class Wombat {
 5:  
 6:   private static final Logger LOGGER = LoggerFactory.getLogger(Wombat.class);
 7:   private Integer t;
 8:   private Integer oldT;
 9:
10:   public void setTemperature(Integer temperature) {
11:    
12:     oldT = t;        
13:     t = temperature;
14:
15:     LOGGER.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
16:
17:     if(temperature.intValue() > 50) {
18:       LOGGER.info("Temperature has risen above 50 degrees.");
19:     }
20:   }
21: } 

The SLF4J Manual can be found here: http://www.slf4j.org/manual.html