PostgreSQL: Important Parameters to enable Log for all Queries

This is one of the important topic for PostgreSQL Database Professional.
A database log is very important to find different statues, error, bad-queries and any changes on the Database Server.
A Database Administrator can also log different executed user query and this is very important for database performance tuning.

In this script, I am sharing some of the important 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)

Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

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

Notify of

Sort by:   newest | oldest | most voted
10 months 18 days ago

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

9 months 7 days ago

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!