Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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                       -/var/log/
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
        news.none;mail.none     -/var/log/debug
        mail,news.none          -/var/log/messages
*.emerg                         *
        *.=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?
share|improve this question
up vote 3 down vote accepted

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:

    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.*.

share|improve this answer
thanks, it seems that I'm using rsyslog and you pointed me to the correct file to edit. Thanks! – user410932 Apr 13 '12 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 '12 at 17:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.