[Spread-users] Re: Log rotation

John Schultz jschultz at commedia.cnds.jhu.edu
Wed Dec 18 10:57:51 EST 2002

An easy way to accomplish what you want would be to write a small program
that reads from stdin and writes to logfiles.  Then pipe spread's output
to this little logger.  Inside the logger you could encode logic about
what files to write to and when. I did this at one point for Spread
because the logfiles were getting too big, too fast with my debugging
flags enabled. I'll scrounge around and see if I can find that code...

This idea might already be encoded in more a more professional logger
implementation somewhere on the Internet, so you might want to poke around
for one.

John Schultz
Co-Founder, Lead Engineer
D-Fusion, Inc. (http://www.d-fusion.net)
Phn: 443 838 2200

On Wed, 18 Dec 2002, Theo E. Schlossnagle wrote:

> Guido van Rossum wrote:
> > I wrote:
> >
> >>Quick question: we need to rotate our logfiles without killing and
> >>restarting the spread daemon.  Can this be done?
> >
> > I already received one answer that doesn't help me.  I'm not asking
> > how to rotate logs.  I'm asking whether, when the logfile is moved,
> > the spread daemon will keep logging to the renamed file or whether it
> > will detect this situation and start logging to the new logfile (with
> > the original name).  IOW does it keep the file descriptor open or not?
> It opens it once and continuously writes to it.  So no, you can't rotate them.
>   Ideally, we would send Spread a SIGHUP and it would close and reopen the log
> file.  On som systems opening a logfile in append mode for every write is uber
> painful. The alternative -- stat'ing the file and checking its inode/device
> numbers for a match and close/reopen on mismatch is a good approach, but it
> causes a stat call for every log line, which is relatively cheap, but
> unnecessary overheadh IMHO.
> Ideally, since spread isn't multithreaded we would set up something like:
> Add an alarm.c function:
> void alarm_reopen_on_next_write();
> which will set a flag that will cause the next write to close the log, reopen
> the log and reset that flag.
> Then we just add a signal handler that calls that function.  This is the way
> spreadlogd works (as well as most other apps) and it works like a charm.
> However, all of the other system calls need to be used in a signal-safe
> manner.  I _think_ that they are already, which would make this modification
> trivial.
> --
> Theo Schlossnagle
> Principal Consultant
> OmniTI Computer Consulting, Inc. -- http://www.omniti.com/
> Phone:  +1 410 872 4910 x201     Fax:  +1 410 872 4911
> 1024D/82844984/95FD 30F1 489E 4613 F22E  491A 7E88 364C 8284 4984
> 2047R/33131B65/71 F7 95 64 49 76 5D BA  3D 90 B9 9F BE 27 24 E7
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users

More information about the Spread-users mailing list