[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    Re: Tomcat v6.0.20 - Cannot Remove Date From JULI Log File Names
From:       "Mark H. Wood" <mwood () IUPUI ! Edu>
Date:       2014-01-30 15:34:15
Message-ID: 20140130153415.GA5719 () IUPUI ! Edu
[Download RAW message or body]


On Wed, Jan 29, 2014 at 10:27:13AM -0500, Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> Mark,
> 
> On 1/29/14, 9:49 AM, Mark H. Wood wrote:
> > On Tue, Jan 28, 2014 at 12:32:22PM -0500, Daniel Mikusa wrote:
> >> On Jan 28, 2014, at 12:05 PM, Vye <vye@vye.me> wrote:
> >>> I have been unsuccessfully trying to remove the date from
> >>> catalina's log file name. My ultimate goal is to logrotate the
> >>> file, which is best done when the file name is static.
> >> 
> >> I'm curious, why are you trying to do this?  The log files are
> >> being rotated out-of-the-box.  They rotate by date, hence why the
> >> date is part of the name.  Why do you need to rotate them with
> >> some other tool?  What doesn't work about the out-of-the-box
> >> configuration?
> > 
> > I agree.  logrotate is a very nice crutch for use when the
> > application doesn't rotate its own logs, but it is better to use
> > the application's rotation code when it exists, since the
> > application (with full knowledge of its internal state) can do this
> > more safely and efficiently than any external tool.
> 
> I actually like logrotate's capabilities for maintaining a set of log
> files: rotate, compress, delete, script, etc.

I agree that logrotate's set of features is quite nice.

> > Cleaning up old log files is easily done with a simple cron job,
> > if the application does not trim old files.  That operation can be
> > done just as well externally as internally.
> 
> Sure, you can do this with scheduled scripts, but it logrotate is
> willing to do that work for you (e.g. easier commands, etc.) why not
> use it?

logrotate works very well for logs created by short-lived processes.
No particular coordination is required, when the source of the log
starts, opens the file, writes a few records, and exits, from time to
time.

Long-running processes require coordination, or else the new file may
sit empty for hours or days while the old file continues to receive
the log entries.  logrotate has ways to handle this:

o  send the process a signal that causes it to close and reopen logs.
   I don't think Tomcat has this.

   jsvc does, and so (if you use jsvc to start Tomcat) you can use
   this to rotate catalina.out.  There's some good stuff about this at
   http://wiki.apache.org/tomcat/FAQ/Logging#Q10 but it's for sysout,
   not logging packages like JULI.  I see some intriguing notes there
   about logrotate's 'copytruncate' option, which I'll have to read up
   on.

o  run a command that somehow causes the process to close and reopen
   logs.  I don't think Tomcat has this.

o  stop and restart the daemon, which forces a close/open of the
   logs.  It takes Tomcat several minutes to restart here, and while
   I'm looking at ways to trim startup time, I really don't want to
   bounce our services *at all* just to tidy the logs.

Thus I prefer to let Tomcat rotate its logs, since it can do that
without interfering with its operation, and to provide scripts to
handle trimming or archiving or other post-processing of the closed
logs.

[just to be thorough]

There are other options in some cases.

o  Apache HTTPD comes with 'rotatelogs', a filter that absorbs text and
   writes it into files with a maximum size, maximum age, date-stamped
   names, etc.  If there's a way to connect log output to a pipeline,
   a daemon that does not contain rotation logic can still have
   rotated log files without restarting.

o  Some syslog packages work well with logrotate (using the signal
   mechanism), so if your daemon can log to syslog then the rotation
   can be handled downstream.

-- 
Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
Machines should not be friendly.  Machines should be obedient.

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic