logging to a file

Started by Vincent Stoesselalmost 24 years ago6 messagesgeneral
Jump to latest
#1Vincent Stoessel
vincent@xaymaca.com

OK, I'm sorry but I have been looking through
the docs and can some tell me how I can specify
a log file to capture my postgres debug messages?
Don't want to use syslog.
Thanks in advance.
--
Vincent Stoessel
Linux Systems Developer
vincent xaymaca.com

#2Jim Caley
caley@chesco.com
In reply to: Vincent Stoessel (#1)
Re: logging to a file

Vincent,

With postmaster you can use redirection (">logfile 2>&1"). With pg_ctl you can
either do that or use the -l option to specify a log file.

Regards,
Jim
--

Vincent Stoessel wrote:

Show quoted text

OK, I'm sorry but I have been looking through
the docs and can some tell me how I can specify
a log file to capture my postgres debug messages?
Don't want to use syslog.
Thanks in advance.

#3Andrew Sullivan
andrew@libertyrms.info
In reply to: Vincent Stoessel (#1)
Re: logging to a file

On Mon, Jun 10, 2002 at 03:20:47PM -0400, Vincent Stoessel wrote:

OK, I'm sorry but I have been looking through
the docs and can some tell me how I can specify
a log file to capture my postgres debug messages?
Don't want to use syslog.

This is a bit of a pin, because you have to redirect the STDOUT from
the postmaster somewhere. The problem is rotating the files.

A colleague of mine wrote a nifty perl script that handles it. I'd
send it along, but as I didn't write it, I can't. (Hint: it uses
IPC::Open3 and IO::Handle.) One serious disadvantage of this
approach is that you can't SIGHUP the postmaster without losing your
logs.

I played with D.J. Bernstein's multilog program, in his daemontools
package (at http://cr.yp.to/daemontools.html). I had it working, but
it seemed a little Byzantine for our needs. I may go back to it,
though, because of the SIGHUP issue, since 7.2.x doesn't read
pg_hba.conf without SIGHUP.

Both of these approaches exact a speed penalty if you use timestamps,
because syslog provides the timestamp info for you, whereas otherwise
the postmaster has to get the time itself. There is a tiny but
measurable difference.

Finally, why not use syslog? Our production environment (or, more
precisely, the hoops required to make any config changes in our
production environment) precludes the use of syslog. But it's
probably the most flexible answer.

A

-- 
----
Andrew Sullivan                               87 Mowat Avenue 
Liberty RMS                           Toronto, Ontario Canada
<andrew@libertyrms.info>                              M6K 3E3
                                         +1 416 646 3304 x110
#4Neil Conway
neilc@samurai.com
In reply to: Vincent Stoessel (#1)
Re: logging to a file

On Mon, 10 Jun 2002 15:20:47 -0400
"Vincent Stoessel" <vincent@xaymaca.com> wrote:

OK, I'm sorry but I have been looking through
the docs and can some tell me how I can specify
a log file to capture my postgres debug messages?

The "-l" option to pg_ctl, or just redirect stderr and stdout
when you start the postmaster.

Cheers,

Neil

--
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vincent Stoessel (#1)
Re: logging to a file

Vincent Stoessel <vincent@xaymaca.com> writes:

OK, I'm sorry but I have been looking through
the docs and can some tell me how I can specify
a log file to capture my postgres debug messages?
Don't want to use syslog.

There's some advice at
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/logfile-maintenance.html

regards, tom lane

#6Arguile
arguile@lucentstudios.com
In reply to: Vincent Stoessel (#1)
Re: logging to a file

Vincent Stoessel writes:

OK, I'm sorry but I have been looking through
the docs and can some tell me how I can specify
a log file to capture my postgres debug messages?
Don't want to use syslog.
Thanks in advance.

As far as I'm aware Pg currently doesn't support multiple named log files
based on message type. Using the standard *nix tools though you can easily
do it though.

First off postmaster -d x (and a postgresql.conf I can't remeber the name
of) controls the level of debugging output, where x is an int from 1 to 5.

To log all output either redirect manually "postmaster > logfile 2>&1 ..."
or use "pg_ctl -l logfile". To get all debugging output you can just "cat
logfile | grep ^DEBUG:" or "tail -f logfile | grep ^DEBUG" if you want a
running tally.

Alternately if you pipe to this first " perl -ne 'BEGIN{open DEBUG,
">>$ENV{PG_DATA}/debug_log"} print DEBUG if /^DEBUG/; print; END{close
DEBUG}' " you echo all the debugging returns into a seperate debug_log
before writing your combined log. You can play all sorts of variations along
the same theme or throw standard log rotators in there as well.