3

I'm running Ubuntu and Postgresql 9.

I've enabled postgresql to log to syslog, and added the following directive to the config file:

 syslog_facility = 'local0'". 

I've tried to configure syslog to log those to a separate file, but that filed. I updtated /etc/syslog.conf so it contains (see last line for the postgresql-directive)

auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
daemon.*                        -/var/log/daemon.log
kern.*                          -/var/log/kern.log
lpr.*                           -/var/log/lpr.log
mail.*                          -/var/log/mail.log
user.*                          -/var/log/user.log
mail.info                       -/var/log/mail.info
mail.warn                       -/var/log/mail.warn
mail.err                        /var/log/mail.err
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice
*.=debug;\
        auth,authpriv.none;\
        news.none;mail.none     -/var/log/debug
*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
        cron,daemon.none;\
        mail,news.none          -/var/log/messages
*.emerg                         *
daemon.*;mail.*;\
        news.err;\
        *.=debug;*.=info;\
        *.=notice;*.=warn       |/dev/xconsole
local0.*                -/var/log/pgsql

I've restarted syslog with "/etc/init.d/sysklogd restart" and with "restart rsyslog".

When postgresql is reloaded, the messages are appended to /var/log/messages and /var/log/syslog ... and not to the correct file as I configured syslog to use...

The same works fine on an other Debian machine with the same version of Postgresql...

any ideas?

  • is something wrong with my syslog config file?
  • should I add something else to my postgresql.conf?
  • can I check if syslog is indeed using the config file that I changed?

1 Answer 1

3

It looks to me like you have a typo in your postgresql.conf file. Make sure that you're actually using

syslog_facility = 'local0'

Also, old syslogd required that hard tabs be used instead of spaces in your config file, so make sure that you aren't actually using spaces, or that your editor isn't converting tabs into spaces (such as the expandtab option in vim).

You also mention both old syslogd and rsyslog, so check to see which one you are actually using. Rsyslog's config file was designed to be backward compatible with syslogd, but does use a different file. So if you are using rsylog then add your logging line to /etc/rsyslog.conf instead.

In order to prevent those messages from also showing up in /var/log/messages you'll need to explicitly filter out that facility. In order to do that, modify your config for messages to this:

*.=info;*.=notice;*.=warn;\
    auth,authpriv.none;\
    cron,daemon.none;\
    mail,news.none;\
    local0.none          -/var/log/messages

That translates to, "Do not write any severity levels from the local0 facility to this file." Or, in effect, exclude anything local0.*.

2
  • thanks, it seems that I'm using rsyslog and you pointed me to the correct file to edit. Thanks!
    – user410932
    Apr 13, 2012 at 17:27
  • do you happen to know how I can prevent rsyslog to log all messages twice? they are now in the /var/log/pgsql file, AND in the /var/log/messages... ?
    – user410932
    Apr 13, 2012 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .