ThingWorx Edge Java SDK > Application Details > Logging
The ThingWorx Edge Java SDK provides logging capabilities that provide a mechanism for writing data to text files. The logging mechanism is designed to isolate logging by class to help you log only what is of interest.
This SDK uses SLF4J (Simple Logging Façade for Java) as a façade for its logging operations, and includes the logback framework ( By using SLF4J, you can incorporate the logging of the SDK into your application, using your chosen logging implementation. For more information, visit
Log Levels
The following log levels are supported:
Trace — The most detailed logs, useful for debugging while you develop an application. Trace logs can provide fine-grained information when tracking down issues that are difficult to find.
Debug — Logs used to help in debugging issues. These log messages contain information about what the code is doing at the moment and the values of any important variables.
Info — Important system information, such as periodic tasks that are running and changes in the state of an application. In most cases, exceptions are not logged at this level
Warn — Unexpected exceptions that are acceptable or that can be worked around. Any problems that could become errors if left unattended.
Error —Issues that affect the usage or performance of the system.
Each level writes out any messages in a lower level. For example, if the logging of the application is set to Trace, then Debug, Info, Warn, and Error levels are written to the log file. If the logging of the application is set to Warn, then only Warn and Error level messages are written to the log.
Logs are very useful for debugging during development or later for troubleshooting an issue. To address an issue, set the log level to Trace, and re-run the application. Review the resulting logs to locate messages that indicate the issue. If you call PTC Technical Support, be prepared and run a trace log first so that you are ready to send it when asked.
The next two sections describe the classes to use for logging in the ThingWorx Edge Java SDK.
LoggerFactory Class
The LoggerFactory class is a helper class that makes logging much simpler than having to create the logging from scratch. It is part of the SLF4J logging.
Logger getLogger(Class clazz) — The getLogger method returns a Logger to perform logging for a specific class. This is usually done on a static, non-modifiable member variable. For example:
// The following line creates a logger based on the SteamThing class
private static final Logger LOG = LoggerFactory.getLogger(SteamThing.class);
Logger Class
The Logger class performs the logging. Methods exist for each log level. Only the most used trace methods are outlined here, but they can all be interpolated from these. The same method signatures are available for debug, info, warn, and error. For more information, visit (logback) or (SLF4J)
All the examples below assume that an instance of the Logger class, named LOG was previously created.
trace(String arg0) — Logs a simple message. For example:
LOG.trace("Initialization complete.");
trace(String arg0, Object arg1) — Logs a message with a single object argument. For example:
LOG.trace("Thing {} has successfully started.", thing.getName());
trace(String arg0, Throwable arg1) — Logs a message with a throwable type as well. For example:
LOG.trace("Exception occurred", e);
trace(String arg0, Object… arg1) — Logs a message with many object arguments. For example:
LOG.trace("Thing {} was started with {} properties at {}", thing.getName(),
thing.getProperties().size(), new DateTime());