You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ashish Sarna <as...@thePSI.com> on 2009/02/03 13:48:54 UTC

Deleting web application specific log files

Hello

 

I am using tomcat6 to deploy my web applications. For logging the messages
which come through 

 

httpServletRequest.getSession().getServletContext().log("Some message");
calls.

 

I have created a logging.properties file, which contains this:

 

handlers = org.apache.juli.FileHandler

 

############################################################

# Handler specific properties.

# Describes specific configuration info for Handlers.

############################################################

 

org.apache.juli.FileHandler.level = FINE

org.apache.juli.FileHandler.directory = ${catalina.base}/logs/myapp

org.apache.juli.FileHandler.prefix = myapp_log.

org.apache.juli.FileHandler.suffix = .txt

 

and have placed this file in tomcat\webapps\myapp\WEB-INF\classes directory.

 

This works perfectly to rotate the log files nightly. But I want to delete
the log files after some time (say, set a property so that log files older
than 5 days are deleted). Is there some way of doing this?

 

java.util.logging.FileHandler has two properties to specify the maximum log
file count and maximum file size :

 

java.util.logging.FileHandler.limit=102400

java.util.logging.FileHandler.count=5 

 

but, when I try to use java.util.logging.FileHandler in place of
org.apache.juli.FileHandler, no messages get logged through
getServletContext().log("Some message"); calls. It seems that tomcat does
not support java.util.logging. Is there a workaround for this?

 

I know I can use Log4J for logging my web application's logs, but that would
require a lot of changes in the existing web application (I would have to
replace all getServletContext().log() calls from log4J specific statements).

 

Any help would be greatly appreciated. Thanks.

 

Regards

Ashish


Re: Deleting web application specific log files

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Asish,

Please do not post your question more than once unless several days have
gone by without a response.

Ashish Sarna wrote:
> I am using tomcat6 to deploy my web applications. For logging the messages
> which come through 
> 
> httpServletRequest.getSession().getServletContext().log("Some message");
> calls.

Note that you can do httpServlet.getServletContext().log("Some message")
if you don't want to depend upon the session.

> This works perfectly to rotate the log files nightly. But I want to delete
> the log files after some time (say, set a property so that log files older
> than 5 days are deleted). Is there some way of doing this?

I believe neither j.u.l.i not log4j include this capability. If you use
size-based rolling, log4j's RollingFileAppender will delete old files
for you.

> java.util.logging.FileHandler has two properties to specify the maximum log
> file count and maximum file size :

This is similar to log4j's capabilities mentioned above.

> java.util.logging.FileHandler.limit=102400
> java.util.logging.FileHandler.count=5 
> 
> but, when I try to use java.util.logging.FileHandler in place of
> org.apache.juli.FileHandler, no messages get logged through
> getServletContext().log("Some message"); calls. It seems that tomcat does
> not support java.util.logging. Is there a workaround for this?

What happens when you use o.a.j.FileHandler with this configuration,
instead of using j.u.l.FileHandler?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmMUQsACgkQ9CaO5/Lv0PDmPQCffZV4FWRpM3DoYnlLF/9d54ob
y+sAoJy/v3MCZ2nLA2EBN5qT/7DY7kEH
=EIQf
-----END PGP SIGNATURE-----

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


RE: Deleting web application specific log files

Posted by Ashish Sarna <as...@thePSI.com>.
 

 

-----Original Message-----
From: Ashish Sarna [mailto:ashish.sarna@thePSI.com] 
Sent: Tuesday, February 03, 2009 6:19 PM
To: users@tomcat.apache.org
Subject: Deleting web application specific log files

 

Hello

 

 

 

I am using tomcat6 to deploy my web applications. For logging the messages

which come through 

 

 

 

httpServletRequest.getSession().getServletContext().log("Some message");

calls.

 

 

 

I have created a logging.properties file, which contains this:

 

 

 

handlers = org.apache.juli.FileHandler

 

 

 

############################################################

 

# Handler specific properties.

 

# Describes specific configuration info for Handlers.

 

############################################################

 

 

 

org.apache.juli.FileHandler.level = FINE

 

org.apache.juli.FileHandler.directory = ${catalina.base}/logs/myapp

 

org.apache.juli.FileHandler.prefix = myapp_log.

 

org.apache.juli.FileHandler.suffix = .txt

 

 

 

and have placed this file in tomcat\webapps\myapp\WEB-INF\classes directory.

 

 

 

This works perfectly to rotate the log files nightly. But I want to delete

the log files after some time (say, set a property so that log files older

than 5 days are deleted). Is there some way of doing this?

 

 

 

java.util.logging.FileHandler has two properties to specify the maximum log

file count and maximum file size :

 

 

 

java.util.logging.FileHandler.limit=102400

 

java.util.logging.FileHandler.count=5 

 

 

 

but, when I try to use java.util.logging.FileHandler in place of

org.apache.juli.FileHandler, no messages get logged through

getServletContext().log("Some message"); calls. It seems that tomcat does

not support java.util.logging. Is there a workaround for this?

 

>> Well, I was wrong here. The java.util.logging provides the solution and
it is supported by tomcat. This resolves my problem.

 

 

I know I can use Log4J for logging my web application's logs, but that would

require a lot of changes in the existing web application (I would have to

replace all getServletContext().log() calls from log4J specific statements).

 

 

 

Any help would be greatly appreciated. Thanks.

 

 

 

Regards

 

Ashish