In this post we will learn how to enable logging in Postgresql 9.2 and 9.1.It is a quick method to enable logging in Postgresql 9.2 and 9.1.We will do changes in postgresql.conf file.

Path in Postgresql 9.1 : /etc/postgresql/9.1/main/postgresql.conf
Path in Postgresql 9.2 : /etc/postgresql/9.2/main/postgresql.conf

To enable the log for all queries in Postgresql,follow the given below steps

Step 1: Take the backup of postgresql.conf file before editing.

In Postgresql 9.1

cp -p  /etc/postgresql/9.1/main/postgresql.conf  /etc/postgresql/9.1/main/postgresql.conf.orig

In Postgresql 9.2

cp -p  /etc/postgresql/9.2/main/postgresql.conf  /etc/postgresql/9.2/main/postgresql.conf.orig

Step 2: Now edit the postgresql.conf file .

For postgresql 9.1

vi /etc/postgresql/9.1/main/postgresql.conf

For postgresql 9.2

vi /etc/postgresql/9.2/main/postgresql.conf

Step 3:

Replace : #log_statement = 'none'
To : log_statement = ‘all’

Replace : #log_min_duration_statement = -1
To: log_min_duration_statement = 0

Save the file.

Step 4: Now restart the postgresql service

/etc/init.d/postgresql restart

Note: The path of log is
/var/log/postgresql/postgresql-9.1-main.log (In Postgresql 9.1)
/var/log/postgresql/postgresql-9.2-main.log (In Postgresql 9.2)

Read Some More Articles

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.