Sunday, September 12, 2010

Sample log4j.xml

As usual, you never find things when you need them, so better have a sample log4j.xml at hand


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
 <appender name="CA" class="org.apache.log4j.ConsoleAppender">
  <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n" />
  </layout>
 </appender>
 <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
  <param name="File" value="c:/temp/log4jlog.log" />
  <param name="MaxFileSize" value="10MB" />
  <param name="MaxBackupIndex" value="3" />
  <param name="Threshold" value="DEBUG" />
  <layout class="org.apache.log4j.PatternLayout">
   <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - %m%n" />
  </layout>
 </appender>
 <logger name="com.acme.osb" additivity="false">
  <level value="DEBUG"/>
  <appender-ref ref="FILE"/>
 </logger>

 <root>
  <level value="WARN" />
  <appender-ref ref="CA" />
 </root>
</log4j:configuration>



No comments: