// postgresql · logging & diagnostics

log_min_error_statement

Also log the SQL text of every statement that raises an error at this severity or higher.

默认
error
Range
debug5, debug4, debug3, debug2, debug1, info, notice, warning, error, log, fatal, panic
Restart needed
否
Default checked on
PostgreSQL 18

作用

The counterpart of log_min_duration_statement, which logs slow statements that succeed. At the default, statements causing ERROR, LOG, FATAL or PANIC are logged with their text; set PANIC to stop logging failing statements entirely.

默认值

error. error (PostgreSQL 18).

Check the current value

SHOW log_min_error_statement;

SELECT setting, unit, boot_val, context, source, pending_restart
FROM pg_settings
WHERE name = 'log_min_error_statement';

Change it

SET log_min_error_statement = warning;   -- this session

ALTER SYSTEM SET log_min_error_statement = warning;
SELECT pg_reload_conf();

No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).

When to change it

Raise it to warning or notice while hunting an application error whose SQL you need to see; lower it to panic only on high-volume systems where the application handles errors and logs them itself.

What can go wrong

Every logged statement carries its full text with parameter values filled in, so errors on tables with personal data put that data in the log. The debug levels on a busy server can produce a log line for most statements the application runs.

Questions about log_min_error_statement

What is the default value of log_min_error_statement in PostgreSQL?

error. error (PostgreSQL 18).

Does changing log_min_error_statement require a restart?

No. No restart. Superusers, or roles granted SET on the parameter (PostgreSQL 15 and later), can SET it per session; a server-wide ALTER SYSTEM change applies after a reload (context is superuser).

When should I change log_min_error_statement?

Raise it to warning or notice while hunting an application error whose SQL you need to see; lower it to panic only on high-volume systems where the application handles errors and logs them itself.

Back to all PostgreSQL settings, or check the PostgreSQL manual for every option.

// one client for every engine

Check log_min_error_statement on your own server

SQLly runs the query above against PostgreSQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

本页文字和数据: CC BY 4.0,请注明出处 SQLly (sqlly.app)。 代码和 SQL 片段: MIT. 许可详情