ThingWorx Edge Java SDK > Application Details > Configuring Logging with logback.xml
Configuring Logging with logback.xml
The configuration of logging using logback requires that you put a logback.xml file on the classpath of the application. An example is presented below, but the configuration of the logback.xml file is beyond the scope of this document. It is recommended that you reference the sites mentioned in Logging for more information. A sample file, called logback-template.xml, is provided in the resources subdirectory of each example project.
* 
The package entered below for logging, com.mycompany, needs to be modified to the name of the package that contains the SteamSensorClient.java and SteamThing.java files.
The following example of the configuration in logback.xml is provided for demonstration purposes:

<configuration>
<!-- Create an appender for standard out using the following format
DateTime [L: LEVEL] [O: class] [T: Thread] message -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSSZ} [L: %level] [O: %logger{8}] [T: %thread]
%msg%n%rootException
</pattern>
</encoder>
</appender>
<!-- Create an appender that will write to a file named
/SteamSensor/Logs/SteamSensor.log. The file will roll
over daily and be named /SteamSensor/Logs/SteamSensor-<date>.0.log
The file will roll over after it reaches 100 MB and be named
/SteamSensor/Logs/SteamSensor-<date>.<count>.log with the following format
DateTime [L: LEVEL] [O: class] [T: Thread] message
-->
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/SteamSensor/Logs/SteamSensor.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>/SteamSensor/Logs/SteamSensor-%d.%i.
logfileNamePattern>/SteamSensor/Logs/SteamSensor-%d.%i.log>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.
rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%date{yyyy-MM-dd HH:mm:ss.SSSZ} [L: %level] [O: %logger{8}]
[T: %thread] %msg%n%rootExceptionpattern>%date{yyyy-MM-dd HH:mm:ss.SSSZ}
[L: %level] [O: %logger{8}] [T: %thread] %msg%n%rootException>
</encoder>
</appender>

<!-- Log the SteamSensor at TRACE level -->
<logger name="com.mycompany" level="TRACE">>/logger>
<!-- Log all classes in the com.ThingWorx namespace at ERROR level -->
<logger name="com.ThingWorx" level="ERROR"></logger>
<!-- Set the default log level to WARN and log to the standard output and to a file -->
<root level="WARN">
<appender-ref ref="STDOUT" />
<appender-ref ref="ROLLING" />
</root>
</configuration>
Was this helpful?