Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

Logging Customization

danbim edited this page Jul 21, 2011 · 5 revisions

Default Behavior

All Testbed Runtime "executables" (i.e. iWSN, RS and SNAA executable JARs) use the helper method Logging.setLoggingDefaults() from the itm-utils project to set a default Log4J Logger and PatternLayout that prints all logging statements to the console. Per default the log level is being set to INFO. The wrapper service that ships with the assembly then takes these console logs and writes them to a log file in the logs/ subdirectory.

Setting the Log Level Using Command Line Parameters

Depending on the startup parameters that are being passed to the executable the log level is being set to the selected level after calling Logging.setLoggingDefaults().

Depending on the executable you can either pass -v for "verbose", or -l TRACE/DEBUG/INFO/WARN/ERROR for setting the level explicitly. In the assembly package you can find these parameters being passed to the executable JAR in the wrapper config files tr.iwsn.conf, tr.rs.conf and tr.snaa.conf in the conf/ subdirectory.

Overriding Logging Behaviour

Users can override default logging behaviour by passing the parameter -Dlog4j.configuration=/path/to/my/log4j.properties to the JVM when starting Testbed Runtime. This file is a standard log4j configuration file configuration file. This e.g. allows you to customize logging behaviour for individual classes.

The same can be achieved by placing your log4j.properties file in the classpath. In this case it will be loaded automatically.

Customizing the Behaviour of the Wrapper Service

The assembly ships with the wrapper services of Java Service Wrapper from Tanuki Software. Many additional settings can be made in the configuration files of the wrapper conf/tr.iwsn.conf, conf/tr.rs.conf and conf/tr.snaa.conf. Please see the Java Service Wrapper homepage for a comprehensive documentation.