Cannot get log_min_duration_statement to work

前端 未结 2 1065
死守一世寂寞
死守一世寂寞 2021-02-06 06:54

I have been googling for more than 2 hours, but I am really stuck with this one.
I want PostgreSQL (I am using version 8.4 on Debian) to start logging slow queries only.

相关标签:
2条回答
  • 2021-02-06 07:13

    Should be:

    log_destination = 'csvlog'
    logging_collector = on
    log_min_duration_statement = 1000
    log_line_prefix = '%t %p %r %d %u '### more context
    log_statement = 'ddl' ### log schema changes 
    
    0 讨论(0)
  • 2021-02-06 07:23
    log_statement = 'all'
    

    instructs the server to log all statements, simple as that. In addition,

    log_duration = on
    

    also instructs the server to log all statements, including duration info.
    Change that to

    log_statement = none
    log_duration = off
    

    No quotes needed. Or comment them out and reload. Then no statement will logged, except those running longer than 1000 ms - instructed by

    log_min_duration_statement = 1000
    

    It's all in the excellent manual.

    0 讨论(0)
提交回复
热议问题