(An intermittent series on PostgreSQL parameters whose default settings you should change.)

Here’s my preferred logging configuration:

1log_destination = 'csvlog'
2logging_collector = on
3log_directory = '/var/log/postgresql'
4log_filename = 'postgresql-%Y%m%d-%H%M%S.log'
5log_rotation_size = 1GB
6log_rotation_age = 1d
7log_min_duration_statement = 250ms
8log_checkpoints = on
9log_connections = on
10log_disconnections = on
11log_lock_waits = on
12log_statement = 'ddl'
13log_temp_files = 0
14log_autovacuum_min_duration = 1000

Of course, you can adjust these to taste. Set log_directory and log_filename as appropriate for your own directory structure and retention policy. (As listed, the log files will build up forever, so some sort of compress-and-delete strategy is required here.) You can set log_min_duration_statement as appropriate to control log volume; if you can get away with log_min_duration_statement = 0, great.

The others should be set as listed on any system; they don’t take up that much in terms of log volume, and the information provided is very helpful.