You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jay <di...@yahoo.com> on 2009/01/11 16:14:23 UTC

Logging configuration in Tomcat

OS : RedHat Linux 
 
Tomcat version : 5.5.20
 
Am able to configure the logging level at individual war files, by referring to log4j.properties in web.xml.
 
Could someone let me know, how to configure the logging level & also the file appender type at global level, please ?
 
Thanks
 
 


      

Re: Logging configuration in Tomcat

Posted by Rusty Wright <ru...@gmail.com>.
If you're looking for a way to have a central log4j file for all apps, that may not be easily done.  I don't know how it is now, but I remember that in previous versions of tomcat sharing tomcat's logging was problematic, which I think may have been due to Commons Logging.

But that's just my hot air; I'm no tomcat expert like the others here.

No matter how much you may think it's a good idea now, I'll bet you that in the future you'll regret it when you're problem solving and need to tweak one app's logging.  Having all of your apps joined at the hips with respect to logging just sounds like something that will cause unforseen problems later on.


Jay wrote:
> OS : RedHat Linux 
>  
> Tomcat version : 5.5.20
>  
> Am able to configure the logging level at individual war files, by referring to log4j.properties in web.xml.
>  
> Could someone let me know, how to configure the logging level & also the file appender type at global level, please ?
>  
> Thanks
>  
>  
> 
> 
>       

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


RE: Logging configuration in Tomcat

Posted by Jay <di...@yahoo.com>.
Chuck
 
Finally I got it working. 
 
As I had said, there were no System.out in my web apps code. They are log4j statements with proper syntax. Just that no log4j configuration is done for each web app. Because of this, tomcat was directing log messages to stdout which was further getting written to catalina.out.
 
Now, I wrote a simple java program, which will redirect stdout & stderr to a print stream which is directed by log4j to a rotating file appender.
 
Thus the problem is solved.
 
Thanks for your help.


--- On Tue, 1/13/09, Caldarale, Charles R <Ch...@unisys.com> wrote:

From: Caldarale, Charles R <Ch...@unisys.com>
Subject: RE: Logging configuration in Tomcat
To: "Tomcat Users List" <us...@tomcat.apache.org>
Date: Tuesday, January 13, 2009, 1:13 PM

> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> Ok. What I am asking is, is there a mechanism to roll
> catalina.out based on size of the file.

You're missing the point.  If you configure log4j properly AND your webapps
do not make direct use of System.out and System.err, there will never be
anything written to catalina.out.  You need to fix your log4j config so it
doesn't use System.out but rather a specific file appender that will rotate
based on size.  You'll need to look at the log4j documentation to figure out
how to do that - this has nothing to do with Tomcat.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




      

RE: Logging configuration in Tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> Ok. What I am asking is, is there a mechanism to roll
> catalina.out based on size of the file.

You're missing the point.  If you configure log4j properly AND your webapps do not make direct use of System.out and System.err, there will never be anything written to catalina.out.  You need to fix your log4j config so it doesn't use System.out but rather a specific file appender that will rotate based on size.  You'll need to look at the log4j documentation to figure out how to do that - this has nothing to do with Tomcat.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Logging configuration in Tomcat

Posted by Jay <di...@yahoo.com>.
Ok. What I am asking is, is there a mechanism to roll catalina.out based on size of the file. 

Thanks

--- On Tue, 1/13/09, Caldarale, Charles R <Ch...@unisys.com> wrote:
From: Caldarale, Charles R <Ch...@unisys.com>
Subject: RE: Logging configuration in Tomcat
To: "Tomcat Users List" <us...@tomcat.apache.org>
Date: Tuesday, January 13, 2009, 11:29 AM

> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> I guess, Tomcat is directing all the log4j log messages
> in the code to system.out which in turn is being written
> to catalina.out

You laboring under a misconception - Tomcat doesn't interact with log4j at
all; where the messages go is entirely dependent on your log4j configuration. 
If you've configured (or misconfigured) log4j to output to System.out (a bad
idea), then log4j messages will go to catalina.out due to the redirection in the
Tomcat startup scripts.  There's nothing in Tomcat that can fix your log4j
config - that's up to you.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




      

RE: Logging configuration in Tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> I guess, Tomcat is directing all the log4j log messages
> in the code to system.out which in turn is being written
> to catalina.out

You laboring under a misconception - Tomcat doesn't interact with log4j at all; where the messages go is entirely dependent on your log4j configuration.  If you've configured (or misconfigured) log4j to output to System.out (a bad idea), then log4j messages will go to catalina.out due to the redirection in the Tomcat startup scripts.  There's nothing in Tomcat that can fix your log4j config - that's up to you.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Logging configuration in Tomcat

Posted by Mark Shifman <ma...@yale.edu>.
Jay wrote:
> Hello
>  
> As we are not providing any log4j configuration for individual web app, I guess, Tomcat is directing all the log4j log messages in the code to system.out which in turn is being written to catalina.out
>  
> Agree that it may not be a good idea to direct log messages from all web apps to a same log file. But, our requirement is that there should be a single file.
> Considering all these, is there a way to achieve rolling for catalina.out, based on size ?
on linux you can use logrotate
http://threebit.net/mail-archive/tomcat-users/msg00444.html

>  
> Thanks
> 
> --- On Mon, 1/12/09, Caldarale, Charles R <Ch...@unisys.com> wrote:
> 
> From: Caldarale, Charles R <Ch...@unisys.com>
> Subject: RE: Logging configuration in Tomcat
> To: "Tomcat Users List" <us...@tomcat.apache.org>
> Date: Monday, January 12, 2009, 6:41 PM
> 
>> From: Jay [mailto:difficult_id@yahoo.com]
>> Subject: RE: Logging configuration in Tomcat
>>
>> There are many web apps. Log4j logger is used in all web apps
>> & there are no system.out  or system.err
> 
> Then where is your catalina.out usage coming from?  Tomcat does not itself put
> anything in catalina.out; data in there appears only because the Tomcat startup
> script redirects System.out and System.err to that file.
> 
>> If I configure log4j at each web app level using
>> log4j.properties, am abile to achive log file rotation but,
>> this requires one log file per web application.
> 
> Which really, really is what you need.  Lumping them all together will create
> serious grief, as other posters have already pointed out.
> 
>> What I am interested is one log file for all web apps
> 
> A bad idea.  You could just merge the log files after they've been
> generated.
> 
>  - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
>       


-- 
 Mark Shifman MD. Ph.D.
 Yale Center for Medical Informatics
 Phone (203)737-5219
 mark.shifman@yale.edu

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


RE: Logging configuration in Tomcat

Posted by Jay <di...@yahoo.com>.
Hello
 
As we are not providing any log4j configuration for individual web app, I guess, Tomcat is directing all the log4j log messages in the code to system.out which in turn is being written to catalina.out
 
Agree that it may not be a good idea to direct log messages from all web apps to a same log file. But, our requirement is that there should be a single file.
Considering all these, is there a way to achieve rolling for catalina.out, based on size ?
 
Thanks

--- On Mon, 1/12/09, Caldarale, Charles R <Ch...@unisys.com> wrote:

From: Caldarale, Charles R <Ch...@unisys.com>
Subject: RE: Logging configuration in Tomcat
To: "Tomcat Users List" <us...@tomcat.apache.org>
Date: Monday, January 12, 2009, 6:41 PM

> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> There are many web apps. Log4j logger is used in all web apps
> & there are no system.out  or system.err

Then where is your catalina.out usage coming from?  Tomcat does not itself put
anything in catalina.out; data in there appears only because the Tomcat startup
script redirects System.out and System.err to that file.

> If I configure log4j at each web app level using
> log4j.properties, am abile to achive log file rotation but,
> this requires one log file per web application.

Which really, really is what you need.  Lumping them all together will create
serious grief, as other posters have already pointed out.

> What I am interested is one log file for all web apps

A bad idea.  You could just merge the log files after they've been
generated.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




      

RE: Logging configuration in Tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> There are many web apps. Log4j logger is used in all web apps
> & there are no system.out  or system.err

Then where is your catalina.out usage coming from?  Tomcat does not itself put anything in catalina.out; data in there appears only because the Tomcat startup script redirects System.out and System.err to that file.

> If I configure log4j at each web app level using
> log4j.properties, am abile to achive log file rotation but,
> this requires one log file per web application.

Which really, really is what you need.  Lumping them all together will create serious grief, as other posters have already pointed out.

> What I am interested is one log file for all web apps

A bad idea.  You could just merge the log files after they've been generated.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Logging configuration in Tomcat

Posted by Jay <di...@yahoo.com>.
Chuck
 
There are many web apps. Log4j logger is used in all web apps & there are no system.out  or system.err

If I configure log4j at each web app level using log4j.properties, am abile to achive log file rotation but, this requires one log file per web application.
 
What I am interested is one log file for all web apps - say catalina,out & this file should be rotated based on size, which should be configurable.
 
Am not Ok with catalina.out being rotated once in a day or once in a month.
 
Could you let me know, how to achieve my requirement, please ?
 
Thanks

--- On Sun, 1/11/09, Caldarale, Charles R <Ch...@unisys.com> wrote:

From: Caldarale, Charles R <Ch...@unisys.com>
Subject: RE: Logging configuration in Tomcat
To: "Tomcat Users List" <us...@tomcat.apache.org>
Date: Sunday, January 11, 2009, 10:34 PM

> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> My actual problem is that, as it is, catalina.out is growing

Sounds like your webapps are using System.out or System.err for their logging,
which is poor practice.  They should be using a proper logging mechanism, not
just splattering print statements wherever they feel like it.

You should be able to address that with the swallowOutput attribute of the
<Context> element:
http://wiki.apache.org/tomcat/FAQ/Logging#Q6
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Set the attribute in conf/context.xml if you want it to apply to all webapps.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




      

RE: Logging configuration in Tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: RE: Logging configuration in Tomcat
>
> My actual problem is that, as it is, catalina.out is growing

Sounds like your webapps are using System.out or System.err for their logging, which is poor practice.  They should be using a proper logging mechanism, not just splattering print statements wherever they feel like it.

You should be able to address that with the swallowOutput attribute of the <Context> element:
http://wiki.apache.org/tomcat/FAQ/Logging#Q6
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Set the attribute in conf/context.xml if you want it to apply to all webapps.

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: Logging configuration in Tomcat

Posted by Jay <di...@yahoo.com>.
Chuck 
 
Thank you for the reply. This is what I was looking for.
 
My actual problem is that, as it is, catalina.out is growing and I want it to be rolled once its size reaches the specified limit. In simple words, I want something like, RollingFileAppender.
 
Could you let me know, how to specify the file size & no of counts for catalina.out, please ?
 
Thanks

--- On Sun, 1/11/09, Caldarale, Charles R <Ch...@unisys.com> wrote:

From: Caldarale, Charles R <Ch...@unisys.com>
Subject: RE: Logging configuration in Tomcat
To: "Tomcat Users List" <us...@tomcat.apache.org>
Date: Sunday, January 11, 2009, 11:28 AM

> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: Logging configuration in Tomcat
>
> Could someone let me know, how to configure the logging level
> & also the file appender type at global level, please ?

Not sure what you mean for "at global level"; if you're asking
about Tomcat's internal logging, that's configured in
conf/logging.properties, which normally uses JULI.  If you want to change that,
look here:
http://tomcat.apache.org/tomcat-5.5-doc/logging.html

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org




      

RE: Logging configuration in Tomcat

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Jay [mailto:difficult_id@yahoo.com]
> Subject: Logging configuration in Tomcat
>
> Could someone let me know, how to configure the logging level
> & also the file appender type at global level, please ?

Not sure what you mean for "at global level"; if you're asking about Tomcat's internal logging, that's configured in conf/logging.properties, which normally uses JULI.  If you want to change that, look here:
http://tomcat.apache.org/tomcat-5.5-doc/logging.html

 - 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 unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org