"Mark Thomas" <[email protected]> wrote in message
news:[email protected]...
> Eric B. wrote:
>> Hi,
>>
> In catalina.properties, modify the following entry as shown:
> common.loader=${catalina.base}/lib,${catalina.home}/lib,${catalina.home}/lib/*.jar
>
> then you can place log4j.properties in CATALINA_BASE/lib
I switched the common.loader as you suggested above, and indeed the
log4j.properties file is now found in the ${catalina.base}/lib directory.
So a good start.
Now, however, I am running into a configuration discrepancy between
logging.properties and the equiv log4j.properties/log4j.xml. I was having
trouble with getting the log4j.properties to "mirror" the
logging.properties, so I swtiched to log4j.xml, but am running into the same
problem:
My webapp uses log4j to log data to stdout. When using Juli (in the default
configuration), everything that is displayed in stdout is logged to
catalina.out. However, when I switch to log4j, this doesn't seem to be the
case; only data that is logged by tomcat is logged to my catalina.out;
anything my webapp is logging to stdout isn't captured in the file.
Original logging.properties (edited non relevant portions for brevity - but
is the default logging.properties file)
handlers = 1catalina.org.apache.juli.FileHandler,
java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler,
java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter =
java.util.logging.SimpleFormatter
So - from that, I read that everything (ie: .handlers) is logged to
1catalina and ConsoleHandler. So far so good.
I tried to replicate this in a log4j.properties/xml with the following
log4j.xml:
<?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.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601}
%-5p %c{5} - %m%n" />
</layout>
</appender>
<!-- stdout logger to catalina.log file -->
<appender name="CatalinaLog"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="file"
value="${catalina.base}/logs/catalina.log" />
<param name="append" value="true" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601}
%-5p %c{5} - %m%n" />
</layout>
</appender>
<!-- Default logger for the entire system -->
<root>
<level value="INFO" />
<appender-ref ref="STDOUT" />
<appender-ref ref="CatalinaLog" />
</root>
</log4j:configuration>
However, I'm not getting the same response. I would have thought that the
log4j's root logger was the equi of the "." logger with juli. Howver, like
I said, I don't get any of the webapp's stdout logging routed to my
CatalinaLog appender/file.
Am I missing something obvious here? Is there a way to mirror juli's
logging with log4j?
Thanks,
Eric
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]