尽管记录了持续时间,但 Postgres 并未记录所有查询

Postgres not logging all queries, despite logging the duration

我正在尝试让我的 postgresql 9.3 服务器记录所有运行时间超过 1 秒的 sql。我已设置:

log_min_duration=1s
log_statement='mod'
log_duration=off

对于大多数查询,日志记录工作正常,但某些语句(例如 "CREATE TABLE AS" 或 "INSERT" 未记录该语句。记录持续时间,但不是完整的 sql.

有没有其他人以前见过这种类型的问题,或者知道为什么 postgres 可能没有记录 sql? (可能是交易块?)非常感谢任何帮助,谢谢。

正确的参数是 log_min_duration_statement 而不是 log_min_duration

还有这篇笔记,来自docs

Note: When using this option together with log_statement, the text of statements that are logged because of log_statement will not be repeated in the duration log message. If you are not using syslog, it is recommended that you log the PID or session ID using log_line_prefix so that you can link the statement message to the later duration message using the process ID or session ID.

考虑是对问题的一个很好的解释。