expanding on syslog help

Started by Christopher Kings-Lynneover 22 years ago7 messages
#1Christopher Kings-Lynne
chriskl@familyhealth.com.au

Hi Guys,

I just spent the last half hour learning syslog and log rolling with
postgres. Would there be objections to me expanding on the syslog
sections in the docs?

http://developer.postgresql.org/docs/postgres/logfile-maintenance.html

I want to:

* Add a link to the third paragraph there where it says to set syslog to
2 that goes to the syslog section of the SET parameters page.

* Give an example of how to configure your syslog.conf to log to a
separate postgres log. eg:

"Depending on your system, to have syslog log PostgreSQL entries to a
particular file, add something like this to the top of your
/etc/syslog.conf:

# Log all 'postgres' events to /var/log/pgsql
!postgres
*.* /var/log/pgsql
# Nothing after this line applies to 'postgres'
!-postgres
"

* Mention that you might want to turn log_pid and log_timestamp off
since syslog logs them anyway

* Mention something about system log rotator? Or is that too
platform-specific?

Chris

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Christopher Kings-Lynne (#1)
Re: expanding on syslog help

Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:

Would there be objections to me expanding on the syslog
sections in the docs?

No, but ...

# Log all 'postgres' events to /var/log/pgsql
!postgres
*.* /var/log/pgsql
# Nothing after this line applies to 'postgres'
!-postgres
"

This example seems not portable in the least; AFAICT neither syntax that
you show is accepted by HPUX's syslogd, for example.

* Mention that you might want to turn log_pid and log_timestamp off
since syslog logs them anyway

Check.

* Mention something about system log rotator? Or is that too
platform-specific?

I think it's reasonable to suggest that syslogd might not solve the
problem all by itself. Dunno if we can give better advice than "read
your local syslogd man page".

regards, tom lane

#3Gaetano Mendola
mendola@bigfoot.com
In reply to: Christopher Kings-Lynne (#1)
Re: expanding on syslog help

Christopher Kings-Lynne wrote:

*.* /var/log/pgsql

With linux is better do:

*.* -/var/log/pgsql

the "-" instruct syslog to not flush on the disk each line received.

BTW in general your instructions are platform dependend

Regards
Gaetano Mendola

#4Larry Rosenman
ler@lerctr.org
In reply to: Christopher Kings-Lynne (#1)
Re: expanding on syslog help

--On Tuesday, September 30, 2003 13:44:04 +0800 Christopher Kings-Lynne
<chriskl@familyhealth.com.au> wrote:

Hi Guys,

[snip]

* Mention something about system log rotator? Or is that too
platform-specific?

newsyslog (FreeBSD base, http://www.courtesan.com/ (Portable) )
is useful. newsyslog may be in the other *BSD's as well.

LER

Chris

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

#5Larry Rosenman
ler@lerctr.org
In reply to: Christopher Kings-Lynne (#1)
Re: expanding on syslog help

--On Tuesday, September 30, 2003 13:44:04 +0800 Christopher Kings-Lynne
<chriskl@familyhealth.com.au> wrote:

Hi Guys,

I just spent the last half hour learning syslog and log rolling with
postgres. Would there be objections to me expanding on the syslog
sections in the docs?

http://developer.postgresql.org/docs/postgres/logfile-maintenance.html

I want to:

* Add a link to the third paragraph there where it says to set syslog to
2 that goes to the syslog section of the SET parameters page.

* Give an example of how to configure your syslog.conf to log to a
separate postgres log. eg:

"Depending on your system, to have syslog log PostgreSQL entries to a
particular file, add something like this to the top of your
/etc/syslog.conf:

# Log all 'postgres' events to /var/log/pgsql
!postgres
*.* /var/log/pgsql
# Nothing after this line applies to 'postgres'
!-postgres
"

a more standard (non-FreeBSD specific) answer is:
local0.* /var/log/postgres.log
(this also works on FreeBSD, btw).

--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

#6Robert Treat
xzilla@users.sourceforge.net
In reply to: Christopher Kings-Lynne (#1)
Re: expanding on syslog help

On Tue, 2003-09-30 at 01:44, Christopher Kings-Lynne wrote:

* Mention that you might want to turn log_pid and log_timestamp off
since syslog logs them anyway

i think that debug_pretty_print is somewhat pointless too, as syslog
tends to wrap lines automagically... could be others.

* Mention something about system log rotator? Or is that too
platform-specific?

"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 the configurations parameter syslog to 2 (to 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. "

Perhaps add:
"If you want to automate the log rotation, the logrotate program can be
configured to work with log files from syslog."

at least, on most linux distros (and I'm just guessing others) this is
how they come configured.

Robert Treat
--
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL

#7Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Robert Treat (#6)
Re: expanding on syslog help

Robert Treat wrote:

On Tue, 2003-09-30 at 01:44, Christopher Kings-Lynne wrote:

* Mention that you might want to turn log_pid and log_timestamp off
since syslog logs them anyway

i think that debug_pretty_print is somewhat pointless too, as syslog
tends to wrap lines automagically... could be others.

* Mention something about system log rotator? Or is that too
platform-specific?

"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 the configurations parameter syslog to 2 (to 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. "

Perhaps add:
"If you want to automate the log rotation, the logrotate program can be
configured to work with log files from syslog."

at least, on most linux distros (and I'm just guessing others) this is
how they come configured.

Added. Thanks.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073