1 For uniform logging in Simantics Platform [ The Simple Logging Facade for Java](http://www.slf4j.org/) (`org.slf4j.api`) and [Logback Project](http://logback.qos.ch/) (`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:
\r
6 An example usage of logging inside your own java code is presented below:
\r
9 1: import org.slf4j.Logger;
\r
10 2: import org.slf4j.LoggerFactory;
\r
12 4: public class Wombat {
\r
14 6: private static final Logger LOGGER = LoggerFactory.getLogger(Wombat.class);
\r
15 7: private Integer t;
\r
16 8: private Integer oldT;
\r
18 10: public void setTemperature(Integer temperature) {
\r
21 13: t = temperature;
\r
23 15: LOGGER.debug("Temperature set to {}. Old temperature was {}.", t, oldT);
\r
25 17: if(temperature.intValue() > 50) {
\r
26 18: LOGGER.info("Temperature has risen above 50 degrees.");
\r
32 The SLF4J Manual can be found here: http://www.slf4j.org/manual.html
\r
34 ## Configuring Logback
\r
36 By default bundle `org.simantics.logback.configuration` contains the `logback.xml` configuration file in which the logging format and different appenders are defined. By default it looks like this:
\r
39 <?xml version="1.0" encoding="UTF-8"?>
\r
42 <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
\r
43 <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
\r
45 <pattern>%-5p [%d] %c: %m%n%rEx</pattern>
\r
49 <appender name="async-console" class="ch.qos.logback.classic.AsyncAppender">
\r
50 <appender-ref ref="console" />
\r
53 <root level="debug">
\r
54 <appender-ref ref="async-console" />
\r
59 This configuration creates a single ''asynchronous'' `ConsoleAppender` which prints all the logging to `System.out` by. An example output would look like:
\r
61 INFO [2016-09-23 15:56:25,498] org.simantics.workbench.internal.SimanticsWorkbenchAdvisor: startPlatform finished
\r
63 It is possible to override this default configuration be giving a VM-argument for the application in format:
\r
65 -Dlogback.configurationFile="C:\logbacs\logback.xml"
\r
67 For detailed information see [Logback manual](http://logback.qos.ch/manual/).
\r