tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gregor Schneider" <rc4...@googlemail.com>
Subject Re: My Log4j statements going crazy in catalina.out
Date Wed, 13 Aug 2008 12:50:42 GMT
Well,

I guess you should vĀ“have a vanilla start with log4j.

Therefore:

1st make sure that you've got all necessary libs installed in the
appropriate folders (guess you're fine here, otherwise no logs would
show up)

2nd create a file $catalina_home/common/classes/log4j.xml with the
following content:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

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

  <!-- Tomcat Daily Rolling File Appender TRACE, DEBUG, INFO -->
  <appender name="TomcatDailyFileAppenderInfo"
class="org.apache.log4j.DailyRollingFileAppender">
    <param name="datePattern" value="'.'yyyy-MM-dd" />
    <param name="Append" value="true" />
    <param name="file" value="${catalina.home}/logs/tomcat.log.INFO" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
             value="%d{ISO8601}\t%-5p\t%X{session}\t%X{file}\t[%t]:\t%m%n" />
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMax" value="INFO"/>
        <param name="LevelMin" value="TRACE"/>
        <param name="AcceptOnMatch" value="true"/>
    </filter>
  </appender>

  <!-- Tomcat Daily Rolling File Appender WARNING -->
  <appender name="TomcatDailyFileAppenderWarning"
class="org.apache.log4j.DailyRollingFileAppender">
    <param name="datePattern" value="'.'yyyy-MM-dd" />
    <param name="Append" value="true" />
    <param name="file" value="${catalina.home}/logs/tomcat.log.WARN" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
             value="%d{ISO8601}\t%-5p\t%X{session}\t%X{file}\t[%t]:\t%m%n" />
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMax" value="WARNING"/>
        <param name="LevelMin" value="WARNING"/>
        <param name="AcceptOnMatch" value="true"/>
    </filter>
  </appender>

  <!-- Tomcat Daily Rolling File Appender ERROR -->
  <appender name="TomcatDailyFileAppenderError"
class="org.apache.log4j.DailyRollingFileAppender">
    <param name="datePattern" value="'.'yyyy-MM-dd" />
    <param name="Append" value="true" />
    <param name="file" value="${catalina.home}/logs/tomcat.log.ERROR" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
             value="%d{ISO8601}\t%-5p\t%X{session}\t%X{file}\t[%t]:\t%m%n" />
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMax" value="ERROR"/>
        <param name="LevelMin" value="ERROR"/>
        <param name="AcceptOnMatch" value="true"/>
    </filter>
  </appender>

  <!-- Tomcat Daily Rolling File Appender FATAL -->
  <appender name="TomcatDailyFileAppenderFatal"
class="org.apache.log4j.DailyRollingFileAppender">
    <param name="datePattern" value="'.'yyyy-MM-dd" />
    <param name="Append" value="true" />
    <param name="file" value="${catalina.home}/logs/tomcat.log.FATAL" />
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"
             value="%d{ISO8601}\t%-5p\t%X{session}\t%X{file}\t[%t]:\t%m%n" />
    </layout>
    <filter class="org.apache.log4j.varia.LevelRangeFilter">
        <param name="LevelMax" value="FATAL"/>
        <param name="LevelMin" value="FATAL"/>
        <param name="AcceptOnMatch" value="true"/>
    </filter>
  </appender>

  <root>
    <level value="info" />
    <appender-ref ref="TomcatDailyFileAppenderInfo" />
    <appender-ref ref="TomcatDailyFileAppenderWarning" />
    <appender-ref ref="TomcatDailyFileAppenderError" />
    <appender-ref ref="TomcatDailyFileAppenderFatal" />
  </root>

</log4j:configuration>

3rd make sure you have the file log4j.dtd in $catalina_home/common/classes

That's it.

If you want your webapp to log, just create the webapp's log4j.xml in
$WEBAPP/WEB-INF/classes


HTH

Gregor
-- 
what's puzzlin' you, is the nature of my game
gpgp-fp: 79A84FA526807026795E4209D3B3FE028B3170B2
gpgp-key available @ http://pgpkeys.pca.dfn.de:11371

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message