Skip to content
jpeterka edited this page Apr 18, 2013 · 9 revisions

Obsolete page !!!

For logging purposes Red Deer uses Apache Log4J library.

Here are instructions for common usage of logging within Red Deer project:

  1. Add org.apache.log4j plugin to Red Deer plugin dependencies within MANIFEST.MF file of Red Deer plugin where logging is needed.

  2. Add this line to the same MANIFEST.MF file Eclipse-RegisterBuddy: org.apache.log4j

  3. Add Log4J configuration file named log4j.xml to src subdirectory of Red Deer plugin. Example of simple log4j.xml can be found here.

  4. Insert creating of Logger instance into the class where logging is going to be used. Define Logger instance as private or protected and use enclosing class or this.getClass() as parameter for method Logger.getLogger(<class>) e.g.

    protected final Logger log = Logger.getLogger(this.getClass());

  5. Use methods of Log instance as appropriate.

To override default configuration stored within plugin do this:

  1. Create custom log4 configuration file with required setting

  2. Use system property log4j.configuration with proper format to specify location of custom log4 configuration file when running tests e.g.

add -D-Dxxxlog4j.configuration=file:/home/reddeertest/custom.xml to Run Configuration > Arguments > VM arguments when running directly from Eclipse IDE.

To check if proper configuration file is used do this:

  1. specify system property log4j.debug. When used Log4J will log his own settings to console. To set this property when running tests from Eclipse IDE do this:

add -Dlog4j.debug to Run Configuration > Arguments > VM arguments when running directly from Eclipse IDE.

JBoss Red Deer - Quick Links

Clone this wiki locally