Well, I got pg_options and syslog (and ELOG timestamping) figured out --
however, there is a quirk:

With syslog set to 2 (supposedly suppressing ANY stderr/stdout, I still get
some output (I know that the documentation mentions this) )-- the output I am
getting is "reset_client_encoding()..  
               reset_client_encoding() done"  immediately after a InitPostgres
log line.  Incidentally, the two reset_client_encoding lines are not
timestamped, while the InitPostgres line IS.

To get syslog functionality working (at least under RedHat Linux 6.1/Intel), do
the following:

Either edit src/include/config.h.in before configure, or edit
src/include/config.h after configure but before make (for RPM-building, I patch
config.h.in before running configure) -- uncomment both ELOG_TIMESTAMPS and
USE_SYSLOG.

In $PGDATA/pg_options, make verbose=1 or 2, and syslog >0 -- read the
pg_options page in the admin docs for more stuff you can put in pg_options.

To get information into the syslog, in /etc/syslog.conf place a line:
local0.*		/var/log/postgresql
and /var/log/postgresql will get ALL those messages.  NICE.  Log rotation under
RedHat is a simple config file in /etc/logrotate.d......

These changes (including the syslog.conf one) will be in the next RPM
set to be released.

Massimo, what syslog levels are you using (I've perused
src/backend/misc/trace.c, but, unfortunately, my knowledge of syslog code is
weak)?

Man, those regression tests really issue the queries (normally, my system will
do the non-parallel regression in about 2:15, but with syslog and query=4, it
takes 3:14).

--
Lamar Owen
WGCR Internet Radio
1 Peter 4:11

Mon, 28 Feb 2000 01:36:58 -0500
Lamar Owen <lamar.owen@wgcr.org>
Syslog and pg_options (for RPMs)
> Well, I got pg_options and syslog (and ELOG timestamping) figured out --
> however, there is a quirk:
> 
> With syslog set to 2 (supposedly suppressing ANY stderr/stdout, I still get
> some output (I know that the documentation mentions this) )-- the output I am
> getting is "reset_client_encoding()..  
>               reset_client_encoding() done"  immediately after a InitPostgres
> log line.  Incidentally, the two reset_client_encoding lines are not
> timestamped, while the InitPostgres line IS.

It seems that there is some code which doesn't use elog() or TPRINTF() but
outputs directly to stderr instead. For example in postgres.c:

#ifdef MULTIBYTE
	/* set default client encoding */
	if (Verbose)
		puts("\treset_client_encoding()..");
	reset_client_encoding();
	if (Verbose)
		puts("\treset_client_encoding() done.");
#endif

In my opinion this is wrong. It should be:

	TPRINTF(TRACE_VERBOSE, "reset_client_encoding().."");

or better:

	TPRINTF(TRACE_MULTYBYTE, "reset_client_encoding().."");

A quick grep shows that the following files contain puts()

    src/backend/access/common/printtup.c:
    src/backend/bootstrap/bootparse.c:
    src/backend/bootstrap/bootstrap.c:
    src/backend/executor/execAmi.c:
    src/backend/libpq/be-dumpdata.c:
    src/backend/nodes/copyfuncs.c:
    src/backend/parser/parse_expr.c:
    src/backend/tcop/postgres.c:
    src/backend/utils/adt/dt.c:
    src/backend/utils/adt/ruleutils.c:
    src/backend/utils/init/postinit.c:
    src/backend/utils/misc/database.c:
    src/backend/utils/sort/lselect.c:
    src/bin/psql/psql.c:
    src/interfaces/libpgtcl/pgtclId.c:

and many other files contain printf().

> To get syslog functionality working (at least under RedHat Linux 6.1/Intel), do
> the following:
> 
> Either edit src/include/config.h.in before configure, or edit
> src/include/config.h after configure but before make (for RPM-building, I patch
> config.h.in before running configure) -- uncomment both ELOG_TIMESTAMPS and
> USE_SYSLOG.

You can also add the following line into Makefile.custom:

CUSTOM_COPT += -DUSE_SYSLOG -DELOG_TIMESTAMPS

> In $PGDATA/pg_options, make verbose=1 or 2, and syslog >0 -- read the
> pg_options page in the admin docs for more stuff you can put in pg_options.
> 
> To get information into the syslog, in /etc/syslog.conf place a line:
> local0.*		/var/log/postgresql
> and /var/log/postgresql will get ALL those messages.  NICE.  Log rotation under
> RedHat is a simple config file in /etc/logrotate.d......
> 
> These changes (including the syslog.conf one) will be in the next RPM
> set to be released.
> 
> Massimo, what syslog levels are you using (I've perused
> src/backend/misc/trace.c, but, unfortunately, my knowledge of syslog code is
> weak)?

LOG_DEBUG, unless you enable the "all" trace flag, in which case LOG_INFO
is used.

> Man, those regression tests really issue the queries (normally, my system will
> do the non-parallel regression in about 2:15, but with syslog and query=4, it
> takes 3:14).
> 
> --
> Lamar Owen
> WGCR Internet Radio
> 1 Peter 4:11
> 
> ************
> 

-- 
Massimo Dal Zotto

+----------------------------------------------------------------------+
|  Massimo Dal Zotto               email: dz@cs.unitn.it               |
|  Via Marconi, 141                phone: ++39-0461534251              |
|  38057 Pergine Valsugana (TN)      www: http://www.cs.unitn.it/~dz/  |
|  Italy                             pgp: finger dz@tango.cs.unitn.it  |
+----------------------------------------------------------------------+


Mon, 28 Feb 2000 19:45:41 +0100 (MET)
Massimo Dal Zotto <dz@cs.unitn.it>
Re: [HACKERS] Syslog and pg_options (for RPMs)