tags:

views:

537

answers:

1

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/"&gt;

    <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-ref 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>
+1  A: 

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).

skaffman
hmmm... I would have suspected that -- at first I wasn't sure whether it was application stdout or log4j writing to stdout, except that I can control the log4j logging format, and that tweaks the output. (see the "ZZZ" note at the top)
Jason S
-1 - no stdout usage, see http://svn.opensymphony.com/fisheye/browse/quartz/branches/quartz_1-6/src/java/org/quartz/plugins/history/LoggingJobHistoryPlugin.java?r=654
fvu
Fair enough, but that doesn't change the way that tomcat works.
skaffman
sure, the question though isn't why stdout is ending up in the Tomcat logs (that's a given, Tomcat even calls it stdout_xxx.log), but why quartz is sending stuff to a stdout-related-log.
Jason S