Vortex Cafe Logging
Jars to use
Depending on your project, you must use a specific jar:
- For a non-Android Java project:
cafe.jar
- For an Android project in debug mode, with logging activated:
cafe-android-debug.jar
- For an Android project in release mode, without logging:
cafe-android.jar
Note that these three jars contain the same core code for Vortex Café, with the same API, options and communication protocol. They differ on only two points:
- Data marshalling/unmarshalling : the implementation of marshalling and unmarshalling of data is based on CORBA classes which are available with the standard JVM, but not with the Android VM. The jars for Android projects contain those classes in addition.
- Android logging back-end : the jar for Android project in debug mode also contains a specific logging back-end for Android. This back-end adds extra load to the application. For better performance, it is strongly advised that you use the jar for release mode.
Logging Activation
Vortex Café logging system is based on SL4J. SL4J is an abstraction layer for various logging frameworks ( e.g. java.util.logging , Log4J, Logback, etc. ) allowing the end user to plug in the desired logging framework at deployment time.
For non-Android platforms, there is no logging by default. You need to add one of the concrete logging frameworks in CLASSPATH , as documented in http://www.slf4j.org/manual.html#swapping.
Note that for Android platforms, the cafe-android-debug.jar
already uses the Android logging framework. If you use this jar, you don’t need to add anything. If you use the cafe-android.jar
the logging is not active.
Example with Logback framework
To use the Logback logging framework with SLF4j, add the logback-core-x.x.x.jar and logback-classic-x.x.x.jar to your CLASSPATH:
CLASSPATH=/path/to/logback-core-1.1.1.jar:/path/to/logback-classic-1.1.1.jar:$CLASSPATH
To configure logback, add a logback.xml file is a directory with is referred by your CLASSPATH.
Here is an example of logback.xml file :
<?xml version="1.0" encoding="UTF-8"?> <configuration> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <!-- Pattern for output are explain here: --> <!-- http://logback.qos.ch/manual/layouts.html --> <!-- %d{ } : time with format --> <!-- %.-1level : level (first character only) --> <!-- %18.18thread : thread name (always 18 characters) --> <!-- %20.20logger : logger name (always 20 characters) --> <!-- %msg : log message --> <!-- %n : line separator (platform dependent) --> <pattern>%d{HH:mm:ss.SSS} %.-1level [%-18.18thread] %-20.20logger : %msg%n</pattern> </encoder> </appender> <root level="${log.level:-INFO}"> <appender-ref ref="STDOUT" /> </root> </configuration>
More information can be found in the Vortex Cafe User Guide.