Re: Log rotation?

From: Giles Lean <giles(at)nemeton(dot)com(dot)au>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Log rotation?
Date: 2001-09-07 21:21:19
Message-ID: 7707.999897679@nemeton.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi Peter,

> I've been playing with a little program I wrote whose sole purpose is to
> write its stdin to a file and close and reopen that file when it receives
> a signal. I figured this could work well when integrated transparently
> into pg_ctl.
>
> So, is log rotation a concern? Is this a reasonable solution? Other
> ideas?

There was a discussion of this over a year ago. After I contributed
to the discussion Tom Lane suggested I write something, and in the
tradition of software development I did so but never quite finished it
... I got to the point that it works for me, then got distracted
before completing a test suite.

You may well prefer your own code, but this one supports rotation on
size and/or time basis as well as on receipt of SIGHUP, and places a
timestamp on each line written. It's also pretty careful about errors,
which is one of the things that was disliked about the Apache program
last time it was discussed.

I am happy to contribute the code using the standard PostgreSQL
license if it's wanted. (If anyone wants it under a BSD license or
GPL for another purpose that's fine too.)

I use the code on HP-UX, and developed it on NetBSD. There shouldn't
be too many portability problems lurking, other than the usual hassles
of what % escape to use in printf() for off_t. I doubt anyone wants
log files larger than a couple of GB anyway? :-)

ftp://ftp.nemeton.com.au/pub/src/logwrite-1.0alpha.tar.gz

> (No Grand Unified Logging Solutions please. And no, "use syslog" doesn't
> count.)

<grin>

One improvement I suggest is that the postmaster be taught to start
(and restart if necessary) the log program. This avoids fragile
startup scripts and also avoids taking down PostgreSQL if someone
sends the wrong signal to the log program.

Cheers,

Giles

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-09-07 21:26:02 Re: Changelog and 7.1.3 release
Previous Message Tom Lane 2001-09-07 20:58:16 Re: Conditional NOTIFY is not implemented