Thread: rotating log files

rotating log files

From
Jelle Ouwerkerk
Date:
Hi

What is a good solution for rotating postgresql log files?

I'm running 'Linux 2.2.16-22smp #1 SMP i686 unknown' and a solution that
was proposed to me was to use cron and a program called logrotate:

DESCRIPTION
       logrotate is designed to ease  administration  of  systems
       that generate large numbers of log files.  It allows auto­
       matic rotation, compression, removal, and mailing  of  log
       files.   Each  log  file  may  be  handled  daily, weekly,
       monthly, or when it grows too large.

Unfortunately, after replacing/rotating/compressing the database log file,
the new log file remains empty. I have a feeling that postgres has lost
the reference to the original log file and that the new log data is lost
into the void.

I'm curious what the consensus is about managing log files.

Thanks

Jelle Ouwerkerk
Software Developer
Openface Internet Inc.
Montreal, Quebec, Canada
http://www.openface.ca


Re: rotating log files

From
Peter Eisentraut
Date:
Jelle Ouwerkerk writes:

> I'm running 'Linux 2.2.16-22smp #1 SMP i686 unknown' and a solution that
> was proposed to me was to use cron and a program called logrotate:

> Unfortunately, after replacing/rotating/compressing the database log file,
> the new log file remains empty. I have a feeling that postgres has lost
> the reference to the original log file and that the new log data is lost
> into the void.

The logrotate program just moves the log file to a different name, but the
PostgreSQL server has the file open so it just keeps writing to the same
file no matter what name it has.  What you need to do is pipe the log
output through a separate program that closes and reopens the file once in
a while.  Apache has such a program, for example.

--
Peter Eisentraut   peter_e@gmx.net   http://funkturm.homeip.net/~peter


Test Message (No Reply Necessary)

From
"Roderick A. Anderson"
Date:
I haven't seen any traffic on the three lists I'm subscribed to.
Testing if message go through.


Rod
--
                 Remove the word 'try' from your vocabulary ...
                     Don't try.  Do it or don't do it ...
                                Steers try!

                                                            Don Aslett