tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "emerson cargnin" <echofloripa.y...@gmail.com>
Subject Re: My Log4j statements going crazy in catalina.out
Date Thu, 14 Aug 2008 11:32:10 GMT
Thanks gregor. This would be to get tomcat to rotate right?

What i was testing was to have a log4j.properties (which I believe is
the same outcome as the log4j.xml) in the common/classes, and commons
logging and log4j jars in the common/lib.

This worked right I had a tomcat.log which rotates and everything. But
my catalina.log continues to get everything, not only the system.out
(which would be expected) but also all the log4j statements.

Here is the log4j.properties in the common/lib:

log4j.rootLogger=ERROR, R
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.File=/opt/resin/tomcat/logs/tomcat.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

I honestly think that tomcat main log should rotate by default. It
also should include even all system.out calls. Maybe the way the
catalina.out is done is flawed?

emerson

On 13/08/2008, Gregor Schneider <rc46fi@googlemail.com> wrote:
> 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
>
>

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