You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jamie <ja...@stimulussoft.com> on 2008/06/17 15:08:40 UTC
logging with multiple web applications
Hi Everyone
Does anyone know how to configure Tomcat such that logging writes to
separate log files for each web application? When we deploy several
instances of our web application, for some reason, the logging output
from all web applications is merged into a single debug.log file.
Apparently, Tomcat uses an extended the log4j package (JULI) to support
logging across multiple web applications, but we are unsure on how to
activate it. I have a feeling we may not be using the right
packages/configuration and would appreciate your guidance.
In our example, each web application has its own log4j.properties file
stored in WEB-INF/classes. The log4j.properties file specifies an
appender with the the location of the debug.log file as follows:
log4j.appender.archivadebug.File=${catalina.home}/logs/debug.log
Even if we specify a different file name for each web application, it
only seems to pickup the first one. It combines logging output from all
web applications into a single log file. Any ideas on why this might be
the same?
Throughout my web application code, I use the following:
import org.apache.log4j.Logger;
..
protected static final Logger logger = Logger.getLogger(Config.class);
..
logger.debug("this is a test log output");
The jar log4j-1.2.14.jar is bundled with the web application and is
located in WEB-INF/lib
How does one make it such that each web application will have its own
log file? For example, say I had the web applications webapp1, and
webapp2 - the debug log file for each could be debug-webapp1.log and
debug-webapp2.log, respectively. Do I need to
import catalina's version of log4j? What is the import line?
Many thanks in advance for your guidance
Jamie
PS: My log4.properties file located in WEB-INF/classes currently looks
like this:
# logging levels
log4j.logger.com.stimulus.archiva.audit=info,archivaaudit
log4j.logger.com.stimulus=DEBUG, archivadebug
#log4j.rootLogger=INFO,archivadebug
#log4j.logger.com.stimulus=warn, mail
#log4j.logger.org.apache.struts=INFO, tomcat
#log4j.logger.org.apache.struts.action=INFO, tomcat
#log4j.logger.org.apache=INFO, tomcat
#log4j.logger.org.apache.commons.digester.Digester= INFO, tomcat
#log4j.logger.org.subethamail.smtp=debug,archivadebug
# debug log
log4j.appender.archivadebug=org.apache.log4j.RollingFileAppender
log4j.appender.archivadebug.File=${catalina.home}/logs/debug.log
log4j.appender.archivadebug.MaxFileSize=200480KB
log4j.appender.archivadebug.layout=org.apache.log4j.PatternLayout
log4j.appender.archivadebug.layout.ConversionPattern=%5p %d{MMM/dd
HH:mm:ss} - %m%n
log4j.appender.archivaaudit.MaxBackupIndex=7
# audit log
log4j.appender.archivaaudit=org.apache.log4j.DailyRollingFileAppender
log4j.appender.archivaaudit.File=${catalina.home}/logs/audit.log
log4j.appender.archivaaudit.layout=org.apache.log4j.PatternLayout
log4j.appender.archivaaudit.layout.ConversionPattern=%5p %d{MMM/dd
HH:mm:ss} - %m%n
log4j.appender.archivaaudit.DatePattern=.yyyy-MM-dd
log4j.appender.archivaaudit.MaxBackupIndex=10000
# tomcat log
log4j.appender.tomcat=org.apache.log4j.RollingFileAppender
log4j.appender.tomcat.File=${catalina.home}/logs/tomcat.log
log4j.appender.tomcat.MaxFileSize=10000KB
log4j.appender.tomcat.layout=org.apache.log4j.PatternLayout
log4j.appender.tomcat.layout.ConversionPattern=%5p %d{MMM/dd HH:mm:ss} -
%m%n
---------------------------------------------------------------------
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
Re: logging with multiple web applications
Posted by David Fisher <df...@jmlafferty.com>.
Hi Chuck,
These threads have clarified things for me as well. Thanks.
>> From: Jamie [mailto:jamie@stimulussoft.com]
>> Subject: Re: logging with multiple web applications
>>
>> Ok. I currently have the log4j-1.2.14.jar file in the WEB-INF/lib
>> directory. I will remove it.
>
> No, that's where it's supposed to be; one copy for each webapp. I
> was referring to Tomcat's lib directory, not each webapp's.
>
>> I do have shared JARs and class files across web apps.
>
> That is most likely the source of your problem.
>
>> This is a strongly desired feature as the intention is to
>> minimize the memory footprint of each web app.
>
> Unless you have many thousands of shared classes, your concern is
> probably unfounded. By introducing such run-time dependencies, you
> pretty much guarantee that you have to take the whole server down
> to update a single webapp, and created versioning hell when you
> need to update a shared library for one particular webapp but not
> the others. Memory is cheap; don't be afraid of configuring a
> larger PermGen when needed.
Yes, this where I am. Memory is not cheap when you are running old
hardware w/o option to replace and have your own webapps large area.
But you are correct about tomcat's reasonable approach to the
problem. I'll need to do containers as singletons. If a webapps is
too PermGen intensive with 4000 clases, etc. maybe it needs its own
isolation.
>> Is there a way to use shared libs/classes and
>> have the logging output separate?
>
> Yes, but it's ugly: each caller of a method in a shared class must
> pass in a reference to the webapp's logger, rather than letting the
> shared class have its own. You really don't want to do that, since
> it complicates and obfuscates the interface. Just stop sharing
> your classes.
Once I put apache in front I can.
I'm not replying in the related classloader thread, but that is
helpful as well in thinking about going from 5.5.25 to 6.
As always - illuminating.
Regards,
Dave
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
> PROPRIETARY MATERIAL and is thus for use only by the intended
> recipient. If you received this in error, please contact the sender
> and delete the e-mail and its attachments from all computers.
>
> ---------------------------------------------------------------------
> 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
RE: logging with multiple web applications
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jamie [mailto:jamie@stimulussoft.com]
> Subject: Re: logging with multiple web applications
>
> Ok. I currently have the log4j-1.2.14.jar file in the WEB-INF/lib
> directory. I will remove it.
No, that's where it's supposed to be; one copy for each webapp. I was referring to Tomcat's lib directory, not each webapp's.
> I do have shared JARs and class files across web apps.
That is most likely the source of your problem.
> This is a strongly desired feature as the intention is to
> minimize the memory footprint of each web app.
Unless you have many thousands of shared classes, your concern is probably unfounded. By introducing such run-time dependencies, you pretty much guarantee that you have to take the whole server down to update a single webapp, and created versioning hell when you need to update a shared library for one particular webapp but not the others. Memory is cheap; don't be afraid of configuring a larger PermGen when needed.
> Is there a way to use shared libs/classes and
> have the logging output separate?
Yes, but it's ugly: each caller of a method in a shared class must pass in a reference to the webapp's logger, rather than letting the shared class have its own. You really don't want to do that, since it complicates and obfuscates the interface. Just stop sharing your classes.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
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
Re: logging with multiple web applications
Posted by Jamie <ja...@stimulussoft.com>.
Hi Charles
Thanks for the help. See below.
Caldarale, Charles R wrote:
>
> The real question is, has the OP read this:
> http://tomcat.apache.org/tomcat-6.0-doc/logging.html
>
> (My guess is that actually has been done as well.) Note that most of the log4j section in the above applies to Tomcat internal logging, not individual webapp logging, except where noted.
>
Yes, I had actually read through that, but as you say, the discussion on
individual web application logging is limited.
> No, JULI is not log4j; JULI is a more flexible replacement for the somewhat restrictive JDK logging mechanism. Internally, Tomcat uses commons-logging, but webapps are free to use whatever they please.
>
I already knew that.
>> each web application has its own log4j.properties file
>> Look for any more global instances of log4j.properties (or log4j.xml) and get rid of them.
>>
Thanks. will do.
>
>> The jar log4j-1.2.14.jar is bundled with the web application
>> and is located in WEB-INF/lib
>> Verify that you don't have any instances of a log4j*.jar in Tomcat's lib directory and that you have no CLASSPATH environment variable set.
>>
Ok. I currently have the log4j-1.2.14.jar file in the WEB-INF/lib
directory. I will remove it.
>> Do I need to import catalina's version of log4j?
>>
>
> No, especially since Tomcat doesn't use log4j, unless you modify it to do so.
>
What is the equivalent import statement to enable access to Catalina's
logger functionality?
>
>> log4j.appender.archivadebug.File=${catalina.home}/logs/debug.log
>>
Will do.
>
> I'd suggest changing all config lines that refer to debug.log to something unique for each webapp.
>
> Have you placed any jars in Tomcat's lib directory that are shared across webapps? If so, and if they are doing any logging, it will use the log4j config of the first webapp to get there. Better to deploy such libraries with each webapp rather than introduce such crosstalk.
>
I do have shared JARs and class files across web apps. This is a
strongly desired feature as the intention is to minimize the memory
footprint of each web app. Is there a way to use shared libs/classes and
have the logging output separate?
---------------------------------------------------------------------
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
RE: logging with multiple web applications
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: André Warnier [mailto:aw@ice-sa.com]
> Subject: Re: logging with multiple web applications
>
> Now Jamie, just a word of caution : this guy Chuck sounds
> like he's nice and wants to help, but don't get your hopes
> up, cause the next time he might just tell you to go read
> the log4j documentation..
Actually, the OP appears to have done that, unlike some...
The real question is, has the OP read this:
http://tomcat.apache.org/tomcat-6.0-doc/logging.html
(My guess is that actually has been done as well.) Note that most of the log4j section in the above applies to Tomcat internal logging, not individual webapp logging, except where noted.
> Apparently, Tomcat uses an extended the log4j package (JULI)
> to support logging across multiple web applications
No, JULI is not log4j; JULI is a more flexible replacement for the somewhat restrictive JDK logging mechanism. Internally, Tomcat uses commons-logging, but webapps are free to use whatever they please.
> each web application has its own log4j.properties file
Look for any more global instances of log4j.properties (or log4j.xml) and get rid of them.
> The jar log4j-1.2.14.jar is bundled with the web application
> and is located in WEB-INF/lib
Verify that you don't have any instances of a log4j*.jar in Tomcat's lib directory and that you have no CLASSPATH environment variable set.
> Do I need to import catalina's version of log4j?
No, especially since Tomcat doesn't use log4j, unless you modify it to do so.
> log4j.appender.archivadebug.File=${catalina.home}/logs/debug.log
I'd suggest changing all config lines that refer to debug.log to something unique for each webapp.
Have you placed any jars in Tomcat's lib directory that are shared across webapps? If so, and if they are doing any logging, it will use the log4j config of the first webapp to get there. Better to deploy such libraries with each webapp rather than introduce such crosstalk.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
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
Re: logging with multiple web applications
Posted by André Warnier <aw...@ice-sa.com>.
Jamie wrote:
> That will be Tomcat version 6.0
>
> Caldarale, Charles R wrote:
>>> From: Jamie [mailto:jamie@stimulussoft.com]
>>> Subject: logging with multiple web applications
>>>
>>> Does anyone know how to configure Tomcat such that logging writes to
>>> separate log files for each web application?
>>>
>>
>> Care to tell anyone what version of Tomcat you're using?
>>
Now Jamie, just a word of caution : this guy Chuck sounds like he's nice
and wants to help, but don't get your hopes up, cause the next time he
might just tell you to go read the log4j documentation..
;-)
Ok, cheap shot.
But just to say that I'm listening too, just in case the answer would
help me understand how it works, and reduce my daily Tomcat logs to
monthly ones.
André
---------------------------------------------------------------------
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
Re: logging with multiple web applications
Posted by Jamie <ja...@stimulussoft.com>.
That will be Tomcat version 6.0
Caldarale, Charles R wrote:
>> From: Jamie [mailto:jamie@stimulussoft.com]
>> Subject: logging with multiple web applications
>>
>> Does anyone know how to configure Tomcat such that logging writes to
>> separate log files for each web application?
>>
>
> Care to tell anyone what version of Tomcat you're using?
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
>
> ---------------------------------------------------------------------
> 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
>
>
--
Stimulus Software - MailArchiva
Email Archiving And Compliance
USA Tel: +1-713-366-8072 ext 3
UK Tel: +44-20-80991035 ext 3
Email: jamie@stimulussoft.com
Web: http://www.mailarchiva.com
---------------------------------------------------------------------
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
RE: logging with multiple web applications
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jamie [mailto:jamie@stimulussoft.com]
> Subject: logging with multiple web applications
>
> Does anyone know how to configure Tomcat such that logging writes to
> separate log files for each web application?
Care to tell anyone what version of Tomcat you're using?
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
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