Thread: using syslog to capture RAISE notices
Can syslog be configured to capture RAISE messages? Reading http://www.postgresql.org/idocs/index.php?plpgsql- description.html#PLPGSQL-DESCRIPTION-ABORTING-AND-MESSAGES, I know how to raise an exception, notice, or debug message. But I've been unable to get those messages logged via syslog. I have this in syslog.conf: *.debug;*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages Here is the test routine I've used: DROP FUNCTION test(); CREATE FUNCTION test() returns int8 AS ' BEGIN raise DEBUG \'this is dan raising a notice\'; RETURN 1; END ' LANGUAGE 'plpgsql'; And the test: fp2rifixed=# select test(); test ------ 1 (1 row) But nothing appears in /var/log/messages (yes, syslogd was HUP'd). FWIW, this is PostgreSQL 7.2 under FreeBSD 4.5. -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples
Strange. I see this in 7.2 elog.c: #ifdef ENABLE_SYSLOG /* Write to syslog, if enabled */ if (Use_syslog >= 1) { int syslog_level; switch (lev) { case DEBUG: syslog_level = LOG_DEBUG; break; case NOTICE: syslog_level I assume you compiled with syslog enabled by configure? Are you seeing anything in syslog or are you just lacking the plpgsql RAISE? --------------------------------------------------------------------------- Dan Langille wrote: > Can syslog be configured to capture RAISE messages? > > Reading http://www.postgresql.org/idocs/index.php?plpgsql- > description.html#PLPGSQL-DESCRIPTION-ABORTING-AND-MESSAGES, I know how to > raise an exception, notice, or debug message. But I've been unable to get > those messages logged via syslog. > > I have this in syslog.conf: > > *.debug;*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages > > Here is the test routine I've used: > > DROP FUNCTION test(); > CREATE FUNCTION test() returns int8 AS ' > BEGIN > raise DEBUG \'this is dan raising a notice\'; > RETURN 1; > END > ' LANGUAGE 'plpgsql'; > > And the test: > > fp2rifixed=# select test(); > test > ------ > 1 > (1 row) > > But nothing appears in /var/log/messages (yes, syslogd was HUP'd). > > FWIW, this is PostgreSQL 7.2 under FreeBSD 4.5. > -- > Dan Langille > The FreeBSD Diary - http://freebsddiary.org/ - practical examples > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
I compiled with the default FreeBSD install: CONFIGURE_ARGS= --enable-locale --enable-syslog --with-CXX \ --docdir=${PREFIX}/share/doc --with- libdir=${LOCALBASE}/lib \ --with-includes=${LOCALBASE}/include What's this Use_syslog? Is that a user configurable item? I am seeing nothing in syslog. The raise is working: test=# CREATE FUNCTION test() returns int8 AS ' test'# BEGIN test'# raise DEBUG \'this is dan raising a notice\'; test'# RETURN 1; test'# END test'# ' LANGUAGE 'plpgsql'; CREATE test=# select test(); test ------ 1 (1 row) test=# On 11 Mar 2002 at 15:46, Bruce Momjian wrote: > > Strange. I see this in 7.2 elog.c: > > #ifdef ENABLE_SYSLOG > /* Write to syslog, if enabled */ > if (Use_syslog >= 1) > { > int syslog_level; > > switch (lev) > { > case DEBUG: > syslog_level = LOG_DEBUG; > break; > case NOTICE: > syslog_level > > I assume you compiled with syslog enabled by configure? Are you seeing > anything in syslog or are you just lacking the plpgsql RAISE? > > > --------------------------------------------------------------------------- > > Dan Langille wrote: > > Can syslog be configured to capture RAISE messages? > > > > Reading http://www.postgresql.org/idocs/index.php?plpgsql- > > description.html#PLPGSQL-DESCRIPTION-ABORTING-AND-MESSAGES, I know how to > > raise an exception, notice, or debug message. But I've been unable to > > get those messages logged via syslog. > > > > I have this in syslog.conf: > > > > *.debug;*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages > > > > Here is the test routine I've used: > > > > DROP FUNCTION test(); > > CREATE FUNCTION test() returns int8 AS ' > > BEGIN > > raise DEBUG \'this is dan raising a notice\'; > > RETURN 1; > > END > > ' LANGUAGE 'plpgsql'; > > > > And the test: > > > > fp2rifixed=# select test(); > > test > > ------ > > 1 > > (1 row) > > > > But nothing appears in /var/log/messages (yes, syslogd was HUP'd). > > > > FWIW, this is PostgreSQL 7.2 under FreeBSD 4.5. > > -- > > Dan Langille > > The FreeBSD Diary - http://freebsddiary.org/ - practical examples > > > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > > -- > Bruce Momjian | http://candle.pha.pa.us > pgman@candle.pha.pa.us | (610) 853-3000 > + If your life is a hard drive, | 830 Blythe Avenue > + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 > -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples
Yes, use postgresql.conf: #syslog = 0 # range 0-2 #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' Set syslog to 1 or 2. Remove # comment character. --------------------------------------------------------------------------- Dan Langille wrote: > I compiled with the default FreeBSD install: > > CONFIGURE_ARGS= --enable-locale --enable-syslog --with-CXX \ > --docdir=${PREFIX}/share/doc --with- > libdir=${LOCALBASE}/lib \ > --with-includes=${LOCALBASE}/include > > What's this Use_syslog? Is that a user configurable item? > I am seeing nothing in syslog. The raise is working: > > test=# CREATE FUNCTION test() returns int8 AS ' > test'# BEGIN > test'# raise DEBUG \'this is dan raising a notice\'; > test'# RETURN 1; > test'# END > test'# ' LANGUAGE 'plpgsql'; > CREATE > test=# select test(); > test > ------ > 1 > (1 row) > > test=# > > On 11 Mar 2002 at 15:46, Bruce Momjian wrote: > > > > > Strange. I see this in 7.2 elog.c: > > > > #ifdef ENABLE_SYSLOG > > /* Write to syslog, if enabled */ > > if (Use_syslog >= 1) > > { > > int syslog_level; > > > > switch (lev) > > { > > case DEBUG: > > syslog_level = LOG_DEBUG; > > break; > > case NOTICE: > > syslog_level > > > > I assume you compiled with syslog enabled by configure? Are you seeing > > anything in syslog or are you just lacking the plpgsql RAISE? > > > > > > --------------------------------------------------------------------------- > > > > Dan Langille wrote: > > > Can syslog be configured to capture RAISE messages? > > > > > > Reading http://www.postgresql.org/idocs/index.php?plpgsql- > > > description.html#PLPGSQL-DESCRIPTION-ABORTING-AND-MESSAGES, I know how to > > > raise an exception, notice, or debug message. But I've been unable to > > > get those messages logged via syslog. > > > > > > I have this in syslog.conf: > > > > > > *.debug;*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages > > > > > > Here is the test routine I've used: > > > > > > DROP FUNCTION test(); > > > CREATE FUNCTION test() returns int8 AS ' > > > BEGIN > > > raise DEBUG \'this is dan raising a notice\'; > > > RETURN 1; > > > END > > > ' LANGUAGE 'plpgsql'; > > > > > > And the test: > > > > > > fp2rifixed=# select test(); > > > test > > > ------ > > > 1 > > > (1 row) > > > > > > But nothing appears in /var/log/messages (yes, syslogd was HUP'd). > > > > > > FWIW, this is PostgreSQL 7.2 under FreeBSD 4.5. > > > -- > > > Dan Langille > > > The FreeBSD Diary - http://freebsddiary.org/ - practical examples > > > > > > > > > ---------------------------(end of broadcast)--------------------------- > > > TIP 4: Don't 'kill -9' the postmaster > > > > > > > -- > > Bruce Momjian | http://candle.pha.pa.us > > pgman@candle.pha.pa.us | (610) 853-3000 > > + If your life is a hard drive, | 830 Blythe Avenue > > + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 > > > > > -- > Dan Langille > The FreeBSD Diary - http://freebsddiary.org/ - practical examples > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
That was it. Thank you. syslog = 2 # range 0-2 For those using FreeBSD, the configuration file is: /usr/local/pgsql/data/postgresql.conf and HUP the running postmaster after your change. Thanks Bruce. On 11 Mar 2002 at 16:33, Bruce Momjian wrote: > > Yes, use postgresql.conf: > > #syslog = 0 # range 0-2 > #syslog_facility = 'LOCAL0' > #syslog_ident = 'postgres' > > Set syslog to 1 or 2. Remove # comment character. > > --------------------------------------------------------------------------- > > Dan Langille wrote: > > I compiled with the default FreeBSD install: > > > > CONFIGURE_ARGS= --enable-locale --enable-syslog --with-CXX \ > > --docdir=${PREFIX}/share/doc --with- > > libdir=${LOCALBASE}/lib \ > > --with-includes=${LOCALBASE}/include > > > > What's this Use_syslog? Is that a user configurable item? > > I am seeing nothing in syslog. The raise is working: > > > > test=# CREATE FUNCTION test() returns int8 AS ' > > test'# BEGIN > > test'# raise DEBUG \'this is dan raising a notice\'; > > test'# RETURN 1; > > test'# END > > test'# ' LANGUAGE 'plpgsql'; > > CREATE > > test=# select test(); > > test > > ------ > > 1 > > (1 row) > > > > test=# > > > > On 11 Mar 2002 at 15:46, Bruce Momjian wrote: > > > > > > > > Strange. I see this in 7.2 elog.c: > > > > > > #ifdef ENABLE_SYSLOG > > > /* Write to syslog, if enabled */ > > > if (Use_syslog >= 1) > > > { > > > int syslog_level; > > > > > > switch (lev) > > > { > > > case DEBUG: > > > syslog_level = LOG_DEBUG; > > > break; > > > case NOTICE: > > > syslog_level > > > > > > I assume you compiled with syslog enabled by configure? Are you seeing > > > anything in syslog or are you just lacking the plpgsql RAISE? > > > > > > > > > ----------------------------------------------------------------------- > > > ---- > > > > > > Dan Langille wrote: > > > > Can syslog be configured to capture RAISE messages? > > > > > > > > Reading http://www.postgresql.org/idocs/index.php?plpgsql- > > > > description.html#PLPGSQL-DESCRIPTION-ABORTING-AND-MESSAGES, I know > > > > how to raise an exception, notice, or debug message. But I've been > > > > unable to get those messages logged via syslog. > > > > > > > > I have this in syslog.conf: > > > > > > > > *.debug;*.notice;kern.debug;lpr.info;mail.crit;news.err > > > > /var/log/messages > > > > > > > > Here is the test routine I've used: > > > > > > > > DROP FUNCTION test(); > > > > CREATE FUNCTION test() returns int8 AS ' > > > > BEGIN > > > > raise DEBUG \'this is dan raising a notice\'; > > > > RETURN 1; > > > > END > > > > ' LANGUAGE 'plpgsql'; > > > > > > > > And the test: > > > > > > > > fp2rifixed=# select test(); > > > > test > > > > ------ > > > > 1 > > > > (1 row) > > > > > > > > But nothing appears in /var/log/messages (yes, syslogd was HUP'd). > > > > > > > > FWIW, this is PostgreSQL 7.2 under FreeBSD 4.5. -- Dan Langille The FreeBSD Diary - http://freebsddiary.org/ - practical examples