start Thu Nov 20 07:19:17 2008 Faculty of Information Technology, UTS
UTS Home | UTS:IT | UTS:IT Contacts | PDF | Documentation | Feedback

Documentation > Solaris Packages > postgresql > logfile-maintenance.html

back...

Log File Maintenance

8.4. Log File Maintenance

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 voluminous (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 OK 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, set syslog to 2 (log to syslog only) in postgresql.conf. Then you can send a SIGHUP signal to the syslog daemon whenever you want to force it to start writing a new log file.

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 PostgreSQL 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.

Last modified: Fri Jul 25 08:49:08 2003

detail...

Messages posted in the last 4 weeks.

· Summer internships available through AIMIA Mobile Internship Program 19/11-30/11
· International Exchange for 2009 - LAST CHANCE 17/11
· Graphics Programing Jobs 17/11-31/12
· Call for Participation - ICSOC'08 Conference and Workshops 17/11
· Phishing attack 'MailBox Quota Alert' (x2) 13/11
· Empower yourself with the ACS Foundation 12/11-15/12 ( 1 )
· The NetSpace Skills Pursuit 2008 Competition is OPEN! 8/11-20/11
· AEAF Finalists 29/10
· Would you like to work on Happy Feet 2? 29/10-30/11
· Are you a web developer? Can you help us with our research? 28/10
· ICSOC 2008 27/10
· Crysis Game Engine 24/10
· 32517 Commerce on the Internet - Now 32120 Introduction to eBusiness Technology 10/8-30/7