Re: rotating log files and adding timestamps to postgres logs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kenny W Drobnack <kenny(dot)w(dot)drobnack(at)jpmchase(dot)com>
Cc: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: rotating log files and adding timestamps to postgres logs
Date: 2009-06-01 17:58:37
Message-ID: 20544.1243879117@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Kenny W Drobnack <kenny(dot)w(dot)drobnack(at)jpmchase(dot)com> writes:
> I'm working with an application running on PostgreSQL 7.4.17 on RedHat
> Enterprise Linux.

You mean Red Hat's RHEL-4 packaging, or somebody else's?

> When asked to troubleshoot a problem, I found out
> the script that starts the PostgreSQL server
> (/etc/rc.d/init.d/postgresql) was logging to /dev/null

Yeah, not the best solution :-(. Later versions of that script do better.

> To try to fix this, I changed PGLOG=/dev/null to
> PGLOG="| /usr/sbin/rotatelogs /var/log/pgsql 86400"

That's not going to work in any shell I know about. You'd have to
actually tweak the script a bit, along the lines of

$SU -l postgres -c "$PGENGINE/postmaster -p ${PGPORT} -D '${PGDATA}' ${PGOPTS} &" >> $PGLOG 2>&1 < /dev/null

becomes

$SU -l postgres -c "$PGENGINE/postmaster -p ${PGPORT} -D '${PGDATA}' ${PGOPTS} &" 2>&1 < /dev/null | /usr/sbin/rotatelogs /var/log/pgsql 86400

> On a related note, I'm currently just doing "PGLOG=/var/log/pgsql".
> It is working, but there are no timestamps in the file except for when
> the database was restarted. Any configuration option that can be
> changed to get timestamps in the log file?

Look at log_line_prefix (I think 7.4 had that, though it's a long time
ago...)

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Kenny W Drobnack 2009-06-01 18:22:19 Re: rotating log files and adding timestamps to postgres logs
Previous Message Chris Browne 2009-06-01 16:40:12 Re: Security question UNIX Sockets vs CIDR style access