Default PostgreSQL logging is quite discreet.

Supposing you would want to log some SQL statements, and in the same time have a more frequent rotation of your logs, here are the lines to change in you postgresql. conf file:

# Changed from -%a to -%a%H%M
log_filename = 'postgresql-%a%H%M.log' # log file name pattern,

# Changed from 1d to 60min
log_rotation_age = 60 # Automatic rotation of logfiles will # happen after that time. 0 disables.

# Changed from 0 to 512k
log_rotation_size = 512 # Automatic rotation of logfiles will # happen after that much log output. # 0 disables.

# Changed from -1 to 0
log_min_duration_statement = 0 # -1 is disabled, 0 logs all statements # and their durations, > 0 logs only # statements running at least this number # of milliseconds

# Changed from none to mod
log_statement = 'mod' # none, ddl, mod, all

Beware of the log_statement parameter on overloaded systems, as your log files might experience some pretty heavy I/O.

Leave me a note if this post has been useful.

Happy computing,