PostgreSQL: Important Parameters to enable Log for all Queries

I am sharing one of the important topics of PostgreSQL Database Professional.

A database log is necessary for finding different statuses, errors, bad queries and any changes on the Database Server.
A Database Administrator can also log different executed queries and analyze it for performance tuning.

Following are few relevant parameters to enable PostgreSQL log for all queries.

Please open your postgresql.conf file and make sure about all logs related parameter’s value which is mentioned here.

  • log_directory = ‘pg_log’ (default directory name)
  • log_filename = ‘postgresql-%Y-%m-%d_%H%M%S.log’ (default file name structure)
  • log_statement = ‘all’ (value ‘all’ is recommended {none, ddl, mod, all})
  • logging_collector = ON
  • log_line_prefix = ‘%t %c %u ‘ (time, sessionid, user)
  • log_destination = ON (stderr,syslog,csvlog,eventlog)
  • log_rotation_size = 15MB
  • log_rotation_age = 1d (create new log file every day)
Anvesh Patel

Leave a Reply

2 Comments on "PostgreSQL: Important Parameters to enable Log for all Queries"

Notify of
Sort by:   newest | oldest | most voted

It’s awesome in support of me to hae a site, which is helpful
in favor of my experience. Thanks admin


First off I would like to say excellent blog! I had a quick question that I’d like to ask if you do not mind.
I was curious to find out how you center yourself and
clear your mind prior to writing. I have had difficulty clearing my thoughts in getting my
ideas out. I truly do take pleasure in writing but it just
seems like the first 10 to 15 minutes are generally wasted simply just trying to figure out how to begin. Any ideas or hints?
Many thanks!