httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: Aha! The conditional logging beast rears its head again
Date Mon, 03 Nov 1997 21:47:43 GMT


On Mon, 3 Nov 1997, Ben Laurie wrote:

> Dean Gaudet wrote:
> > 
> > Just because users ask for a feature doesn't mean we have to implement it
> > the way they ask for it.  You know my opinion on this topic.  For example,
> > here we go, here's conditional logging for 1.3:
> > 
> >     TransferLog "| pidthing /path/to/pidfile grep -v 'do your best' >>/path/to/access_log"
> > 
> > And here's an easier way to rotate logs for 1.3 without doing a full
> > server restar:
> > 
> >     TransferLog "| pidthing /path/to/pidfile cat >>/path/to/access_log"
> > 
> > Where pidthing is the following sh script:
> > 
> >     #!/bin/sh
> >     if [ $# -lt 2 ]; then
> >         echo "usage: $0 pidfile_path program_to_exec [args ...]" 1>&2
> >         exit 1
> >     fi
> >     if ! echo $$ > $1; then
> >         echo "can't write pidfile" 1>&2
> >         exit 1
> >     fi
> >     shift
> >     exec ${1+"$@"}
> >     echo "exec failed" 1>&2
> >     exit 1
> > 
> > Impressive, no?  The unix philosophy at its best.
> 
> So impressive I don't understand it :-)
> 
> Actually, I presume the idea is you kill the cat from time to time?
> Perhaps the script should be called "schroedinger"? :-)

Yup, the pidthing writes the pid of the cat/grep/whatever to a file, and
you can do the usual "kill `cat logger.pid`" to rotate logs.

Dean


Mime
View raw message