about 1 year ago

I work on a Ubuntu (14.04) machine with Postgres 9.4 installed. The config file directory of Postgres is located at:


Inside the config file, uncomment and adjust the following lines:

log_destination = 'stderr, csvlog'  # save logs as .log file and a .csv file

logging_collector = on # required to be on for csvlogs

log_directory = '/var/log/postgresql' # use any directory the postgres user have read and write access to. /var/log/postgresql is a pretty good place to start with

log_filename = 'postgresql-%Y-%m-%d_%H%M.log' # modify the %modifiers to suit your need

log_truncate_on_rotation = on # should logs be saved in separated files instead of one gigantic file

log_rotation_age = 1d # save the logs into a new file everyday. If you'd rather seperate files based on file size, modify log_rotation_size instead of this one

log_line_prefix = '%t [%p-%l] %q%u@%d ' # what information should each line of logs include

log_statement = 'all' # check out here for more info: http://www.postgresql.org/docs/9.4/static/runtime-config-logging.html#GUC-LOG-STATEMENT

log_timezone = 'Asia/Shanghai' # what timezone should be used for timestamp each log

These are the basic options I enabled, and to make this new change effective immediately, restart postgres by:

sudo service postgresql restart

For more config explanation, check the official doc here

← Linting React Babel projects Config SSH to be more secure →
comments powered by Disqus