Wiki / Configuration Parameters
log_statement
Controls which SQL statements are logged. Valid values are none (off), ddl, mod, and all (all statements). ddl logs all data definition statements, such as CREATE, ALTER, and DROP statements. mod logs all ddl statements, plus data-modifying statements such as INSERT, UPDATE, DELETE, TRUNCATE, and COPY FROM. PREPARE, EXECUTE, and EXPLAIN ANALYZE statements are also logged if their contained command is of an appropriate type. For clients using extended query protocol, logging occurs when an Execute message is received, and values of the Bind parameters are included (with any embedded single-quote marks doubled). The default is none. Only superusers and users with the appropriate SET privilege can change this setting. Note Statements that contain simple syntax errors are not logged even by the log_statement = all setting, because the log message is emitted only after basic parsing has been done to determine the statement type. In the case of extended query protocol, this setting likewise does not log statements that fail before the Execute phase (i.e., during parse analysis or planning). Set log_min_error_statement to ERROR (or lower) to log such statements. Logged statements might reveal sensitive data and even contain plaintext passwords.
English manual coverage begins with PostgreSQL 7.4. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- boot val
- none
- category
- Reporting and Logging / What to Log
- context
- superuser
- doc same as
- Unknown
- documented
- true
- enumvals
- none, ddl, mod, all
- extra desc
- Unknown
- lang
- en
- max val
- Unknown
- metadata version
- 18
- min val
- Unknown
- name
- log_statement
- short desc
- Sets the type of statements logged.
- source
- pg-settings-source-snapshot
- unit
- Unknown
- vartype
- enum
Definition PG 18
Controls which SQL statements are logged. Valid values are
none (off), ddl, mod, and
all (all statements). ddl logs all data definition
statements, such as CREATE, ALTER, and
DROP statements. mod logs all
ddl statements, plus data-modifying statements
such as INSERT,
UPDATE, DELETE, TRUNCATE,
and COPY FROM.
PREPARE, EXECUTE, and
EXPLAIN ANALYZE statements are also logged if their
contained command is of an appropriate type. For clients using
extended query protocol, logging occurs when an Execute message
is received, and values of the Bind parameters are included
(with any embedded single-quote marks doubled).
The default is none.
Only superusers and users with the appropriate SET
privilege can change this setting.
Note
Statements that contain simple syntax errors are not logged
even by the log_statement = all setting,
because the log message is emitted only after basic parsing has
been done to determine the statement type. In the case of extended
query protocol, this setting likewise does not log statements that
fail before the Execute phase (i.e., during parse analysis or
planning). Set log_min_error_statement to
ERROR (or lower) to log such statements.
Logged statements might reveal sensitive data and even contain plaintext passwords.
Compare versions
Complete source facts
doc html
<p>
Controls which SQL statements are logged. Valid values are
<code class="literal">none</code> (off), <code class="literal">ddl</code>, <code class="literal">mod</code>, and
<code class="literal">all</code> (all statements). <code class="literal">ddl</code> logs all data definition
statements, such as <code class="command">CREATE</code>, <code class="command">ALTER</code>, and
<code class="command">DROP</code> statements. <code class="literal">mod</code> logs all
<code class="literal">ddl</code> statements, plus data-modifying statements
such as <code class="command">INSERT</code>,
<code class="command">UPDATE</code>, <code class="command">DELETE</code>, <code class="command">TRUNCATE</code>,
and <code class="command">COPY FROM</code>.
<code class="command">PREPARE</code>, <code class="command">EXECUTE</code>, and
<code class="command">EXPLAIN ANALYZE</code> statements are also logged if their
contained command is of an appropriate type. For clients using
extended query protocol, logging occurs when an Execute message
is received, and values of the Bind parameters are included
(with any embedded single-quote marks doubled).
</p><p>
The default is <code class="literal">none</code>.
Only superusers and users with the appropriate <code class="literal">SET</code>
privilege can change this setting.
</p><div class="note"><h3 class="title">Note</h3><p>
Statements that contain simple syntax errors are not logged
even by the <code class="varname">log_statement</code> = <code class="literal">all</code> setting,
because the log message is emitted only after basic parsing has
been done to determine the statement type. In the case of extended
query protocol, this setting likewise does not log statements that
fail before the Execute phase (i.e., during parse analysis or
planning). Set <code class="varname">log_min_error_statement</code> to
<code class="literal">ERROR</code> (or lower) to log such statements.
</p><p>
Logged statements might reveal sensitive data and even contain
plaintext passwords.
</p></div>documentation revision
{"inputs":[{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","version":"18.7"},{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"68c010254e1859ec0b76f06a563babd51a6c38997f1242e35e4c6b649724b1cb","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · wiki-repair-20261023:e3c328d21138ffe93c38fba42e7e784d70f7c559489cd0d3da24af4cf1731222
Text language: en · wiki-repair-20261023:e3c328d21138ffe93c38fba42e7e784d70f7c559489cd0d3da24af4cf1731222