13 February 2012

Minimal log4j.xml configuration file template

Here a log4j.xml file template, providing a minimal log4j's configuration that enables console output and DEBUG logging level for a given base package - logging level is set to WARN for remaining packages.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
 <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
  <param name="Target" value="System.out" />
  <param name="Threshold" value="DEBUG" />
  <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern"
    value="%d{ABSOLUTE} %-5p [%c{1}] %m%n" />
 <!-- Insert your own base-package HERE! -->
 <logger name="org.amicofragile">
  <level value="DEBUG" />
  <priority value="WARN" />
  <appender-ref ref="CONSOLE" />
Official log4j.xml documentation 

No comments:

Post a Comment