Re: [PORTS] Logging (was Re: PostgreSQL 7.0-2 RPMset released.)

From: Palle Girgensohn <girgen(at)partitur(dot)se>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Lamar Owen <lamar(dot)owen(at)wgcr(dot)org>, Thomas Good <tomg(at)admin(dot)nrnet(dot)org>, pgsql-ports(at)postgreSQL(dot)org, "PostgreSQL::General List" <pgsql-general(at)postgreSQL(dot)org>, teg(at)redhat(dot)com, Richard Smith <ozric(at)tampabay(dot)rr(dot)com>
Subject: Re: [PORTS] Logging (was Re: PostgreSQL 7.0-2 RPMset released.)
Date: 2000-05-22 15:02:37
Message-ID: 39294C0D.F53BE202@partitur.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-announce pgsql-general pgsql-hackers pgsql-ports

Tom Lane wrote:
>
> Lamar Owen <lamar(dot)owen(at)wgcr(dot)org> writes:
> > The real problem with redirecting the postmaster output is the issue
> > of log rolling, which is impossible to do in the 'classic'
> > stderr/stdout redirect UNLESS you throw down postmaster when rolling
> > the log (unless you know a trick I don't).

I think I do ;-) read on...

> Yes. I think ultimately we will have to do some logging support code of
> our own to make this work the way we want. My thought at the moment is
> there's nothing wrong with logging to stderr, as long as there's some
> code somewhere that periodically closes stderr and reopens it to a new
> log file. There needn't be a lot of code involved, we just need a
> well-thought-out spec for how it should work. Comments anyone?
>
> regards, tom lane

I really enjoy using apache's rotatelogs program. stderr is
redirected through a pipe to a very small and robust C program,
rotatelogs, that takes as arguments number of seconds between
log rotates and the log filename. Logs are rotated every
argv[2] seconds. The rotatelogs program takes care of closing
and reopening, and nothing has to done from the application,
just start postmaster with '2>&1 | rotatelogs ...' at the end,
and log to stderr.

Also, BSD license! :)

For reference, I enclose the program as an attachment; it's
less than 100 lines. Also, here's the man page:

Name
rotatelogs - rotate Apache logs without having to kill
the
server

Synopsis
rotatelogs logfile rotationtime

Description
rotatelogs is a simple program for use in conjunction
with
Apache's piped logfile feature which can be used
like
this:

TransferLog "|rotatelogs
/path/to/logs/access_log
86400"

This creates the files /path/to/logs/access_log.nnnn
where
nnnn is the system time at which the log nominally
starts
(this time will always be a multiple of the rotation
time,
so you can synchronize cron scripts with it). At the
end
of each rotation time (here after 24 hours) a new log
is
started.

Options
logfile
The path plus basename of the logfile. The
suffix
.nnnn is automatically added.

rotationtime
The rotation time in seconds.

See Also
httpd(8)

Attachment Content-Type Size
rotatelogs.c.orig text/plain 1.8 KB

In response to

Responses

Browse pgsql-announce by date

  From Date Subject
Next Message Peter Eisentraut 2000-05-22 21:58:33 Re: [PORTS] Logging (was Re: PostgreSQL 7.0-2 RPMset released.)
Previous Message Giles Lean 2000-05-22 06:43:00 Re: Logging (was Re: PostgreSQL 7.0-2 RPMset released.)

Browse pgsql-general by date

  From Date Subject
Next Message Dirk Lutzebaeck 2000-05-22 15:25:04 performance and number of selected columns
Previous Message Horák Daniel 2000-05-22 11:49:10 RE: pgsql for win

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2000-05-22 15:37:12 Re: Last call for comments: fmgr rewrite [LONG]
Previous Message Karl DeBisschop 2000-05-22 13:17:22 Re: Thus spoke SQL3 (on OO)

Browse pgsql-ports by date

  From Date Subject
Next Message Murad Nayal 2000-05-22 16:42:48 port v7.0 to SGI-IRIX-6.5.7/64
Previous Message Giles Lean 2000-05-22 06:43:00 Re: Logging (was Re: PostgreSQL 7.0-2 RPMset released.)