Re: rotating log files and adding timestamps to postgres logs - Mailing list pgsql-admin

From Tom Lane
Subject Re: rotating log files and adding timestamps to postgres logs
Date
Msg-id 20544.1243879117@sss.pgh.pa.us
Whole thread Raw
In response to rotating log files and adding timestamps to postgres logs  (Kenny W Drobnack <kenny.w.drobnack@jpmchase.com>)
Responses Re: rotating log files and adding timestamps to postgres logs  (Kenny W Drobnack <kenny.w.drobnack@jpmchase.com>)
Re: rotating log files and adding timestamps to postgres logs  (Kenny W Drobnack <kenny.w.drobnack@jpmchase.com>)
List pgsql-admin
Kenny W Drobnack <kenny.w.drobnack@jpmchase.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

pgsql-admin by date:

Previous
From: Kenny W Drobnack
Date:
Subject: rotating log files and adding timestamps to postgres logs
Next
From: Kenny W Drobnack
Date:
Subject: Re: rotating log files and adding timestamps to postgres logs