postgres logging_collector sending to two directories simultaneously

615 views Asked by At

In the course of testing logging for a postgres server we discovered logs were being sent to two different directories simultaneously.

The two locations were:

  • /var/lib/postgresql/9.6/main/pg_log/ (intended)
  • /var/log/postgresql/ (uninteded)

Settings changed in postgresql.conf prior:

logging_collector = on
log_destination = 'csvlog'

Settings in postgresql.conf not changed, but relevant:

log_directory = 'pg_log'
log_truncate_on_rotation = off

I'm aware that both directories are standard for postgres logging, but sending to both simultaneously seems unusual.

We were testing logging for a day, and both sets of logs were created on that day.

1

There are 1 answers

7
Laurenz Albe On

You must be using the Debian/Ubuntu packages for PostgreSQL.

The packagers have opted to not use PostgreSQL' logging_collector, but rather have the processes write the messages to standard error. These messages are then collected in a log file in /var/log/postgresql, and log rotation is applied to them (see the startup script for how they did it).

Now if you configure logging in PostgreSQL like you did, the log will be written to log_directory, but the startup process hasn't changed: it still creates a file in /var/log/postgresql, but now only the first few messages after the startup end there, then PostgreSQL switches to using its log file.