You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Felipe Jaekel <fk...@gmail.com> on 2013/03/05 14:54:01 UTC

Limit log files rotation

Hi,

I'd like to limit log rotation to a specific number of days to avoid that
the logs folder keep growing indeterminately.

Tried to google about, people say to study Log4j or use crontab,
but isn't there an easier way like a *maxHistory* property?

Thanks,
Phillip

Re: Limit log files rotation

Posted by Daniel Mikusa <dm...@vmware.com>.
On Mar 5, 2013, at 12:40 PM, Felipe Jaekel wrote:

> Thanks for the link.
> 
> Searching a bit more I found this:
> http://www.queuemetrics.com/manuals/QM_AdvancedConfig-chunked/ar01s17.html

Watch out when using "logrotate" with the "copytruncate" option, in some circumstances this can result in data loss.

> 
> Simple to setup, but anyway it would be nice if Tomcat could do this out of
> the box, since the server can crash if it runs out of disk space.

Tomcat offers several ways to handle logging out-of-the-box, including the one you mentioned.  I believe it's documented here.

  https://wiki.apache.org/tomcat/FAQ/Logging

Dan


> 
> 
> 2013/3/5 Daniel Mikusa <dm...@vmware.com>
> 
>> On Mar 5, 2013, at 8:54 AM, Felipe Jaekel wrote:
>> 
>>> Hi,
>>> 
>>> I'd like to limit log rotation to a specific number of days to avoid that
>>> the logs folder keep growing indeterminately.
>> 
>> Which log files are you referring to?  Including the names would help.
>> 
>>> 
>>> Tried to google about, people say to study Log4j or use crontab,
>>> but isn't there an easier way like a *maxHistory* property?
>> 
>> Tomcat's default logging mechanism will simply rotate files.  It does not
>> perform any cleanup or archival.
>> 
>> If you want those features, you have two choices …
>> 
>> 1.) Setup a cron job to cleanup or archive old log files.
>> 2.) Use Tomcat's log4j support.  Log4j supports cleanup and archival.
>> 
>>  https://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
>> 
>> There's probably other things you can do as well.  Those are just the
>> first two that popped into my head.
>> 
>> Dan
>> 
>>> 
>>> Thanks,
>>> Phillip
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
>> 

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


Re: Limit log files rotation

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

Felipe,

On 3/5/13 11:40 AM, Felipe Jaekel wrote:
> Searching a bit more I found this: 
> http://www.queuemetrics.com/manuals/QM_AdvancedConfig-chunked/ar01s17.html
>
>  Simple to setup, but anyway it would be nice if Tomcat could do
> this out of the box, since the server can crash if it runs out of
> disk space.

This is entirely the point of using logrotate: it does one job, and it
does it well. It fits-in very well with the UNIX philosophy. Embrace it.

Apache httpd also doesn't rotate its own log files, though it can be
taught to do it, either using their own logger service or... using
logrotate. Note that neither of these solutions is really httpd doing
the work: it's some external tool, though httpd does make it somewhat
easier. (Copytruncate always seemed like such a hack to me, but it
definitely makes the daemon process simpler to write and manage).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlE2074ACgkQ9CaO5/Lv0PCb6ACeNrjD00b7DrwTTDQb/xMeL/2h
r2AAoIHuIMbnuZ+B2fTuHT9DIY6Tkd77
=o32q
-----END PGP SIGNATURE-----

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


Re: Limit log files rotation

Posted by Felipe Jaekel <fk...@gmail.com>.
Thanks for the link.

Searching a bit more I found this:
http://www.queuemetrics.com/manuals/QM_AdvancedConfig-chunked/ar01s17.html

Simple to setup, but anyway it would be nice if Tomcat could do this out of
the box, since the server can crash if it runs out of disk space.


2013/3/5 Daniel Mikusa <dm...@vmware.com>

> On Mar 5, 2013, at 8:54 AM, Felipe Jaekel wrote:
>
> > Hi,
> >
> > I'd like to limit log rotation to a specific number of days to avoid that
> > the logs folder keep growing indeterminately.
>
> Which log files are you referring to?  Including the names would help.
>
> >
> > Tried to google about, people say to study Log4j or use crontab,
> > but isn't there an easier way like a *maxHistory* property?
>
> Tomcat's default logging mechanism will simply rotate files.  It does not
> perform any cleanup or archival.
>
> If you want those features, you have two choices …
>
> 1.) Setup a cron job to cleanup or archive old log files.
> 2.) Use Tomcat's log4j support.  Log4j supports cleanup and archival.
>
>   https://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j
>
> There's probably other things you can do as well.  Those are just the
> first two that popped into my head.
>
> Dan
>
> >
> > Thanks,
> > Phillip
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Limit log files rotation

Posted by Daniel Mikusa <dm...@vmware.com>.
On Mar 5, 2013, at 8:54 AM, Felipe Jaekel wrote:

> Hi,
> 
> I'd like to limit log rotation to a specific number of days to avoid that
> the logs folder keep growing indeterminately.

Which log files are you referring to?  Including the names would help.

> 
> Tried to google about, people say to study Log4j or use crontab,
> but isn't there an easier way like a *maxHistory* property?

Tomcat's default logging mechanism will simply rotate files.  It does not perform any cleanup or archival.

If you want those features, you have two choices …

1.) Setup a cron job to cleanup or archive old log files.
2.) Use Tomcat's log4j support.  Log4j supports cleanup and archival.

  https://tomcat.apache.org/tomcat-7.0-doc/logging.html#Using_Log4j

There's probably other things you can do as well.  Those are just the first two that popped into my head.

Dan

> 
> Thanks,
> Phillip

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