2010. 5. 26. 18:24

Log4J XML설정 예제

Log4j XML설정 예제. Propery형식보다는 XML이 권장되고 있고, 개인적으로 XML이 더 깔끔해보임
 

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

 

       <!-- Console view -->

       <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">

             <layout class="org.apache.log4j.PatternLayout">

                    <param name="ConversionPattern" value="%d [%t] %p - %C{1}.%M(%L) | %m%n" />

             </layout>

       </appender>

 

       <appender name="OKCPN" class="org.apache.log4j.DailyRollingFileAppender">

             <param name="file" valueru" />

             <param name="Append" value="true" />

             <param name="Encoding" value="EUC-KR" />

             <param name="DatePattern" value="'.'yyyy-MM-dd" />

             <layout class="org.apache.log4j.PatternLayout">

                    <param name="ConversionPattern" value="%5p [%d{HH:mm:ss}] %m%n" />

             </layout>

       </appender>

 

       <appender name="SQL" class="org.apache.log4j.DailyRollingFileAppender">

             <param name="file" value="/usr/local/tomcat-5.5.23/webapps/okcpn/log/sql.log" />

             <param name="Append" value="true" />

             <param name="Encoding" value="EUC-KR" />

             <param name="DatePattern" value="'.'yyyy-MM-dd" />

             <layout class="org.apache.log4j.PatternLayout">

                    <param name="ConversionPattern" value="%5p [%d{HH:mm:ss}] %m%n" />

             </layout>

       </appender>

 

       <logger name="com.incross" additivity="false">

             <level value="DEBUG" />

             <appender-ref ref="OKCPN" />

       </logger>

 

       <logger name="org.apache" additivity="false">

             <level value="WARN" />

             <appender-ref ref="OKCPN" />

             <appender-ref ref="SQL" />

       </logger>

 

       <logger name="org.springframework" additivity="false">

             <level value="INFO" />

             <appender-ref ref="OKCPN" />

             <appender-ref ref="SQL" />

       </logger>

 

       <logger name="com.ibatis" additivity="false">

             <level value="DEBUG" />

             <appender-ref ref="SQL" />

       </logger>

 

       <logger name="java.sql" additivity="false">

             <level value="DEBUG" />

             <appender-ref ref="SQL" />

       </logger>

</log4j:configuration>

 


'OpenSource > Log4J' 카테고리의 다른 글

Log4J XML설정 예제  (0) 2010.05.26
Log4J 간단 사용법  (1) 2009.11.18
Trackback 0 Comment 0