开发者

help with log4j.xml

I have a dilemma configuring my log4j.xml (attached below) for the Quartz web-app.

It is spitting out log messages to stdout (which my Tomcat instance then logs) for INFO reported by Quartz's LoggingJobHistory plugin. It is using the "stdout" appender defined below; I can tell this because I put the "ZZZ" there and it makes its way into the Tomcat log.

I can't figure out why, though. The only things that are using the "stdout" appender are root and org.apache, both setup for WARN. Why am I getting INFO messages?

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <!-- <layout class="org.apache.log4j.TTCCLayout"/> -->
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="ZZZ %d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
        </layout>
    </appender>

    <appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="${quartz.root}/WEB-INF/logs/quartz-log.txt"/> <!-- orther options ${user.home} -->
        <param name="DatePattern" value="'.'yyyy-MM-dd"/> 
        <param name="Append" value="true"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
        </layout>
    </appender>

    <appender name="appFILE" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="${quartz.root}/WEB-INF/logs/app-log.txt"/> <!-- orther options ${user.home} -->
        <param name="DatePattern" value="'.'yyyy-MM-dd"/> 
        <param name="Append" value="true"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
        </layout>
    </appender>

     <appender name="HtmlAppender" class="org.apache.log4j.DailyRollingFileAppender">
            <param name="File" value="${quartz.root}/WEB-INF/logs/ShortResults.html"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd-HH'.html'"/>
        <layout class="org.apache.log4j.HTMLLayout"/>
          <!--/layout-->
        </appender>         

    <!-- log detail configuration -->
    <logger name="org.quartz">
        <level value="info"/> 
        <appender-re开发者_高级运维f ref="FILE"/>
        <appender-ref ref="HtmlAppender"/>  
    </logger>

    <logger name="com.opensymphony">
        <level value="info"/>
        <appender-ref ref="HtmlAppender"/>
    </logger>

    <logger name="org.apache">
        <level value="warn"/>
        <appender-ref ref="stdout"/>
    </logger>

    <root>
        <level value="warn"/>
        <appender-ref ref="stdout"/>
        <appender-ref ref="FILE"/>
    </root>


</log4j:configuration>


Tomcat intercepts all output to stdout and stderr and redirects them to log4j. Any application code that uses stdout or stderr will therefore appear in the usual log4j log files.

I suspect the LoggingJobHistory plugin is writing stuff to stdout, which is poor practice, but not terribly surpring (the Quartz codebase isn't exactly top notch).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜