How to log PostgreSQL queries?

2020-01-22 12:33发布

How to enable logging of all SQL executed by PostgreSQL 8.3?

Edited (more info) I changed these lines :

log_directory = 'pg_log'                    
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_statement = 'all'

And restart PostgreSQL service... but no log was created... I'm using Windows Server 2003.

Any ideas?

9条回答
Anthone
2楼-- · 2020-01-22 13:26
Luminary・发光体
3楼-- · 2020-01-22 13:29

+1 to above answers. I use following config

log_line_prefix = '%t %c %u ' # time sessionid user
log_statement = 'all'
查看更多
孤傲高冷的网名
4楼-- · 2020-01-22 13:32

You also need add these lines in PostgreSQL and restart the server:

log_directory = 'pg_log'                    
log_filename = 'postgresql-dateformat.log'
log_statement = 'all'
logging_collector = on
查看更多
登录 后发表回答