From bb2ff5f2d4593854816c05992a5d24b3af88b000 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 20 Nov 2001 04:27:49 +0000 Subject: [PATCH] Expand discussion of logfile management a little bit. --- doc/src/sgml/maintenance.sgml | 63 ++++++++++++++++++++++++++++++++--- doc/src/sgml/runtime.sgml | 8 +++-- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index f58af65ca7..2f3e080212 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -1,5 +1,5 @@ @@ -34,10 +34,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.7 2001/11/18 22:17:30 - It is also necessary to rotate the database server log file that is specified - when the postmaster is started. If you are using - syslog, you can send a SIGHUP - signal to the syslog daemon to force it to start writing a new log file. + Something else that might need periodic attention is log file management. + This is discussed in . @@ -367,6 +365,61 @@ VACUUM + + + Log File Maintenance + + + log files + + + + It's a good idea to save the database server's log output somewhere, + rather than just routing it to /dev/null. The log output + is invaluable when it comes time to diagnose problems. However, the + log output tends to be voluminuous (especially at higher debug levels) + and you won't want to save it indefinitely. You need to rotate + the log files so that new log files are started and old ones thrown + away every so often. + + + + If you simply direct the postmaster's stderr into a file, the only way + to truncate the log file is to stop and restart the postmaster. This + may be okay for development setups but you won't want to run a production + server that way. + + + + The simplest production-grade approach to managing log output is to send it + all to syslog and let syslog deal with file + rotation. To do this, make sure Postgres was built with + the + + + On many systems, however, syslog is not very reliable, particularly + with large log messages; it may truncate or drop messages just when + you need them the most. You may find it more useful to pipe the + postmaster's stderr to some type of log rotation script. + If you start the postmaster with pg_ctl, then the + postmaster's stderr is already redirected to stdout, so you just need a + pipe command: + + +pg_ctl start | logrotate + + + The Postgres distribution doesn't include a suitable + log rotation program, but there are many available on the net; + one is included in the Apache distribution, for example. + + @@ -171,9 +171,11 @@ NOTICE: Initializing database with en_US collation order. > postmaster -D /usr/local/pgsql/data > logfile 2>&1 & - It is an extremely good idea to keep the server output around - somewhere, as indicated here. It will help both for auditing + It is an extremely good idea to keep the server's stdout and stderr + output around somewhere, as suggested here. It will help both for auditing purposes and to diagnose problems. + (See for a more thorough discussion + of logfile handling.)