Menu

Wednesday, July 6, 2011

Log4j - Console Appender

Console Appender configuration in log4j.properties

  • 01.log4j.rootLogger=DEBUG, stdout, file, rolling, daily
  • 02.log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  • 03.log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  • 04.log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} [%t] %-2p %c - %m%n

Console Appender configuration in log4j.xml

  • 01. <?xml version="1.0" encoding="UTF-8" ?>
  • 02. <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
  • 03. 
  • 04. <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  • 05.    <!-- Console Appender -->
  • 06.     <appender name="console" class="org.apache.log4j.ConsoleAppender">
  • 07.         <param name="Target" value="System.out"/>
  • 08.         <layout class="org.apache.log4j.PatternLayout">
  • 09.             <param name="ConversionPattern" value="%-5p%c{1}-%m%n"/>
  • 10.         </layout>
  • 11.     </appender>
  • 12. 
  • 13.    <root>
  • 14.         <priority value ="debug"/>
  • 15.         <appender-ref ref="console"/>
  • 16.     </root>
  • 17. </log4j:configuration>