사용자 도구

사이트 도구


java:log4j

문서의 이전 판입니다!


Log4j

additivity

  • 중복으로 로그가 쌓인다면, 로거에 additivity 속성을 false로 지정한다.

비동기 로깅

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
<log4j:configuration>
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p %c %x - %m%n"/>
        </layout>
    </appender>
    <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
        <param name="BufferSize" value="500"/>
        <appender-ref ref="stdout"/>
    </appender>
    <root>
        <priority value="error"></priority>
        <appender-ref ref="ASYNC"/>
    </root>
</log4j:configuration>
  • 주의 할 점들
    • If you see duplicated entries on your log, make sure your logger has the additivity attribute set to false.
    • The BufferSize parameter of the AsyncAppender defines the number of entries that will be stored in memory to let the actual appender catch up flushing them to their final destination. If this buffer fills up, the logging will switch to a synchronous mode until buffer space becomes available, potentially becoming a performance issue. Make sure this buffer is big enough, taking into account the IO speed and number of log entries generated by your application.
    • You can add the Blocking parameter to the AsyncAppender definition in your config file, if you set it to false (the default value is true) when the buffer fills up, the appender will discard log events until new buffer space becomes available. This can be unacceptable in applications where logging information is critical, but on the other hand can be very desirable where performance is a critical factor.
java/log4j.1354677174.txt.gz · 마지막으로 수정됨: 2012/12/05 12:12 저자 kwon37xi