PostgreSQL - Logging

Modify /etc/postgresql/9.5/main/postgresql.conf:

logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql.log'
log_line_prefix = '[%m] – %p %q- %[email protected]%h:%d – %a '
log_statement = 'all'

Modify /etc/logrotate.d/postgresql-common:

/var/lib/postgresql/9.5/main/pg_log/*.log {
       daily
       rotate 10
       copytruncate
       delaycompress
       compress
       notifempty
       missingok
       su root root
}