Wiki / Configuration Parameters
log_destination
PostgreSQL supports several methods for logging server messages, including stderr, csvlog, jsonlog, and syslog. On Windows, eventlog is also supported. Set this parameter to a list of desired log destinations separated by commas. The default is to log to stderr only. This parameter can only be set in the postgresql.conf file or on the server command line. If csvlog is included in log_destination, log entries are output in “comma-separated value” (CSV) format, which is convenient for loading logs into programs. See Section 19.8.4 for details. logging_collector must be enabled to generate CSV-format log output. If jsonlog is included in log_destination, log entries are output in JSON format, which is convenient for loading logs into programs. See Section 19.8.5 for details. logging_collector must be enabled to generate JSON-format log output. When either stderr, csvlog or jsonlog are included, the file current_logfiles is created to record the location of the log file(s) currently in use by the logging collector and the associated logging destination. This provides a convenient way to find the logs currently in use by the instance. Here is an example of this file's content: stderr log/postgresql.log csvlog log/postgresql.csv jsonlog log/postgresql.json current_logfiles is recreated when a new log file is created as an effect of rotation, and when log_destination is reloaded. It is removed when none of stderr, csvlog or jsonlog are included in log_destination, and when the logging collector is disabled. Note On most Unix systems, you will need to alter the configuration of your system's syslog daemon in order to make use of the syslog option for log_destination. PostgreSQL can log to syslog facilities LOCAL0 through LOCAL7 (see syslog_facility), but the default syslog configuration on most platforms will discard all such messages. You will need to add something like: local0.* /var/log/postgresql to the syslog daemon's configuration file to make it work. On Windows, when you use the eventlog option for log_destination, you should register an event source and its library with the operating system so that the Windows Event Viewer can display event log messages cleanly. See Section 18.12 for details.
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
- stderr
- category
- Reporting and Logging / Where to Log
- context
- sighup
- doc same as
- Unknown
- documented
- true
- enumvals
- Unknown
- extra desc
- Valid values are combinations of "stderr", "syslog", "csvlog", "jsonlog", and "eventlog", depending on the platform.
- lang
- en
- max val
- Unknown
- metadata version
- 18
- min val
- Unknown
- name
- log_destination
- short desc
- Sets the destination for server log output.
- source
- pg-settings-source-snapshot
- unit
- Unknown
- vartype
- string
Definition PG 18
PostgreSQL supports several methods
for logging server messages, including
stderr, csvlog,
jsonlog, and
syslog. On Windows,
eventlog is also supported. Set this
parameter to a list of desired log destinations separated by
commas. The default is to log to stderr
only.
This parameter can only be set in the postgresql.conf
file or on the server command line.
If csvlog is included in log_destination,
log entries are output in “comma-separated
value” (CSV) format, which is convenient for
loading logs into programs.
See Section 19.8.4 for details.
logging_collector must be enabled to generate
CSV-format log output.
If jsonlog is included in
log_destination, log entries are output in
JSON format, which is convenient for loading logs
into programs.
See Section 19.8.5 for details.
logging_collector must be enabled to generate
JSON-format log output.
When either stderr,
csvlog or jsonlog are
included, the file current_logfiles is created to
record the location of the log file(s) currently in use by the logging
collector and the associated logging destination. This provides a
convenient way to find the logs currently in use by the instance. Here
is an example of this file's content:
stderr log/postgresql.log csvlog log/postgresql.csv jsonlog log/postgresql.json
current_logfiles is recreated when a new log file
is created as an effect of rotation, and
when log_destination is reloaded. It is removed when
none of stderr,
csvlog or jsonlog are
included in log_destination, and when the logging
collector is disabled.
Note
On most Unix systems, you will need to alter the configuration of
your system's syslog daemon in order
to make use of the syslog option for
log_destination. PostgreSQL
can log to syslog facilities
LOCAL0 through LOCAL7 (see syslog_facility), but the default
syslog configuration on most platforms
will discard all such messages. You will need to add something like:
local0.* /var/log/postgresql
to the syslog daemon's configuration file to make it work.
On Windows, when you use the eventlog
option for log_destination, you should
register an event source and its library with the operating
system so that the Windows Event Viewer can display event
log messages cleanly.
See Section 18.12 for details.
Compare versions
Complete source facts
doc html
<p>
<span class="productname">PostgreSQL</span> supports several methods
for logging server messages, including
<span class="systemitem">stderr</span>, <span class="systemitem">csvlog</span>,
<span class="systemitem">jsonlog</span>, and
<span class="systemitem">syslog</span>. On Windows,
<span class="systemitem">eventlog</span> is also supported. Set this
parameter to a list of desired log destinations separated by
commas. The default is to log to <span class="systemitem">stderr</span>
only.
This parameter can only be set in the <code class="filename">postgresql.conf</code>
file or on the server command line.
</p><p>
If <span class="systemitem">csvlog</span> is included in <code class="varname">log_destination</code>,
log entries are output in <span class="quote">“<span class="quote">comma-separated
value</span>”</span> (<acronym class="acronym">CSV</acronym>) format, which is convenient for
loading logs into programs.
See <a class="xref" href="/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-CSVLOG" title="19.8.4. Using CSV-Format Log Output">Section 19.8.4</a> for details.
<a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOGGING-COLLECTOR">logging_collector</a> must be enabled to generate
CSV-format log output.
</p><p>
If <span class="systemitem">jsonlog</span> is included in
<code class="varname">log_destination</code>, log entries are output in
<acronym class="acronym">JSON</acronym> format, which is convenient for loading logs
into programs.
See <a class="xref" href="/docs/18/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-JSONLOG" title="19.8.5. Using JSON-Format Log Output">Section 19.8.5</a> for details.
<a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOGGING-COLLECTOR">logging_collector</a> must be enabled to generate
JSON-format log output.
</p><p>
When either <span class="systemitem">stderr</span>,
<span class="systemitem">csvlog</span> or <span class="systemitem">jsonlog</span> are
included, the file <code class="filename">current_logfiles</code> is created to
record the location of the log file(s) currently in use by the logging
collector and the associated logging destination. This provides a
convenient way to find the logs currently in use by the instance. Here
is an example of this file's content:
</p><pre class="programlisting">
stderr log/postgresql.log
csvlog log/postgresql.csv
jsonlog log/postgresql.json
</pre><p>
<code class="filename">current_logfiles</code> is recreated when a new log file
is created as an effect of rotation, and
when <code class="varname">log_destination</code> is reloaded. It is removed when
none of <span class="systemitem">stderr</span>,
<span class="systemitem">csvlog</span> or <span class="systemitem">jsonlog</span> are
included in <code class="varname">log_destination</code>, and when the logging
collector is disabled.
</p><div class="note"><h3 class="title">Note</h3><p>
On most Unix systems, you will need to alter the configuration of
your system's <span class="application">syslog</span> daemon in order
to make use of the <span class="systemitem">syslog</span> option for
<code class="varname">log_destination</code>. <span class="productname">PostgreSQL</span>
can log to <span class="application">syslog</span> facilities
<code class="literal">LOCAL0</code> through <code class="literal">LOCAL7</code> (see <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-SYSLOG-FACILITY">syslog_facility</a>), but the default
<span class="application">syslog</span> configuration on most platforms
will discard all such messages. You will need to add something like:
</p><pre class="programlisting">
local0.* /var/log/postgresql
</pre><p>
to the <span class="application">syslog</span> daemon's configuration file
to make it work.
</p><p>
On Windows, when you use the <code class="literal">eventlog</code>
option for <code class="varname">log_destination</code>, you should
register an event source and its library with the operating
system so that the Windows Event Viewer can display event
log messages cleanly.
See <a class="xref" href="/docs/18/event-log-registration.html" title="18.12. Registering Event Log on Windows">Section 18.12</a> for details.
</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:7e76ee9d164ebe1de91d59012f4bb4f911d1e2636a7ba4e4f8577178cd8bd20f
Text language: en · wiki-repair-20261023:7e76ee9d164ebe1de91d59012f4bb4f911d1e2636a7ba4e4f8577178cd8bd20f