logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michał Straczyński <m.straczyn...@pentacomp.com.pl>
Subject Log4j & Tomcat once more
Date Wed, 09 Oct 2002 15:51:25 GMT
Hello!
  I'm using Tomcat 4.0.5 and Log4j 1.2.6, there are 2 webapps deployed in
Tomcat, each of them should  log messages to the separated files using
Log4j. Ok, I've read some advices posted here and on the other lists in the
net  but I they seem no to work. Of course everything works fine if each
webapp has it's own copy of log4j.jar in WEB-INF/lib. The problem is that in
the production env. log4j library is required (by client) to be global. So I
put log4j in $CATALINA_HOME\lib and the log4j.properties file (source below
with comments)  in $CATALINA_HOME\classes.

log4j.additivity.org.apache=false
log4j.additivity.com.penta=false
log4j.additivity.com.mike=false

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

#  logfile for first app - packages com.penta
#

log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=e:/users/mst/log/ASMonitor.log
log4j.appender.file.Append=true
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

# logfile for 2nd app - packages com.mike
#

log4j.appender.file2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file2.File=e:/users/mst/log/TestApp.log
log4j.appender.file2.Append=true
log4j.appender.file2.DatePattern='.'yyyy-MM-dd
log4j.appender.file2.layout=org.apache.log4j.PatternLayout
log4j.appender.file2.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

log4j.logger.com.mike=DEBUG, file2
log4j.logger.org.apache=ERROR, stdout
log4j.logger.com.penta=DEBUG, file
log4j.rootCategory=DEBUG, stdout

>From what I've understood reading documentation, etc. my servlet
com.penta.ASMonitor should be logging to the e:/users/mst/log/ASMonitor.log
file, and servlet com.mike.TestApp sholud be logged to
e:/users/mst/log/TestApp.log. Unfortunately neither 1st one nor 2nd one are
logged. I have no idea!

Then I deleted log4j.properties form $CATALINA_HOME/classes and made two
different files for each app that I put into WEB-INF/classes directories.

for ASMonitor :
log4j.debug=true

log4j.additivity.org.apache=false
log4j.additivity.com.penta=false

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.File=e:/users/mst/log/ASMonitor.log
log4j.appender.file.Append=true
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

log4j.logger.org.apache=ERROR, file
log4j.logger.com.penta=DEBUG, file
log4j.rootCategory=DEBUG, file

for TestApp:
log4j.debug=true

log4j.additivity.org.apache=false
log4j.additivity.com.mike=false

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

log4j.appender.file2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file2.File=e:/users/mst/log/TestApp.log
log4j.appender.file2.Append=true
log4j.appender.file2.DatePattern='.'yyyy-MM-dd
log4j.appender.file2.layout=org.apache.log4j.PatternLayout
log4j.appender.file2.layout.ConversionPattern=%-5p - %d{dd MMM
yyyy/HH:mm:ss}; %m \n

log4j.logger.org.apache=ERROR, file2
log4j.logger.com.mike=DEBUG, file2
log4j.rootCategory=DEBUG, file2

It doesn't work too. Both apps are logged to e:/users/mst/log/ASMonitor.log
. It seems for me that both of them are using the same configuration (of
ASMonitor that is initialized before TestApp). As I've read somewhere this
was supposed to work considering the fact that in Tomcat4 every webapp has
it's own classloader.  Am I doing something wrong?

So the question is: is there any way to use global log4j library for
different webapps running on the same appserver?
 Michal Straczynski





--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@jakarta.apache.org>


Mime
View raw message