↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / Configuration Parameters

log_filename

When logging_collector is enabled, this parameter sets the file names of the created log files. The value is treated as a strftime pattern, so %-escapes can be used to specify time-varying file names. (Note that if there are any time-zone-dependent %-escapes, the computation is done in the zone specified by log_timezone.) The supported %-escapes are similar to those listed in the Open Group's strftime specification. Note that the system's strftime is not used directly, so platform-specific (nonstandard) extensions do not work. The default is postgresql-%Y-%m-%d_%H%M%S.log. If you specify a file name without escapes, you should plan to use a log rotation utility to avoid eventually filling the entire disk. In releases prior to 8.4, if no % escapes were present, PostgreSQL would append the epoch of the new log file's creation time, but this is no longer the case. If CSV-format output is enabled in log_destination, .csv will be appended to the timestamped log file name to create the file name for CSV-format output. (If log_filename ends in .log, the suffix is replaced instead.) If JSON-format output is enabled in log_destination, .json will be appended to the timestamped log file name to create the file name for JSON-format output. (If log_filename ends in .log, the suffix is replaced instead.) This parameter can only be set in the postgresql.conf file or on the server command line.

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
postgresql-%Y-%m-%d_%H%M%S.log
category
Reporting and Logging / Where to Log
context
sighup
doc same as
Unknown
documented
true
enumvals
Unknown
extra desc
Unknown
lang
en
max val
Unknown
metadata version
18
min val
Unknown
name
log_filename
short desc
Sets the file name pattern for log files.
source
pg-settings-source-snapshot
unit
Unknown
vartype
string

Definition PG 18

When logging_collector is enabled, this parameter sets the file names of the created log files. The value is treated as a strftime pattern, so %-escapes can be used to specify time-varying file names. (Note that if there are any time-zone-dependent %-escapes, the computation is done in the zone specified by log_timezone.) The supported %-escapes are similar to those listed in the Open Group's strftime specification. Note that the system's strftime is not used directly, so platform-specific (nonstandard) extensions do not work. The default is postgresql-%Y-%m-%d_%H%M%S.log.

If you specify a file name without escapes, you should plan to use a log rotation utility to avoid eventually filling the entire disk. In releases prior to 8.4, if no % escapes were present, PostgreSQL would append the epoch of the new log file's creation time, but this is no longer the case.

If CSV-format output is enabled in log_destination, .csv will be appended to the timestamped log file name to create the file name for CSV-format output. (If log_filename ends in .log, the suffix is replaced instead.)

If JSON-format output is enabled in log_destination, .json will be appended to the timestamped log file name to create the file name for JSON-format output. (If log_filename ends in .log, the suffix is replaced instead.)

This parameter can only be set in the postgresql.conf file or on the server command line.

Compare versions

Complete source facts

doc html

<p>
        When <code class="varname">logging_collector</code> is enabled,
        this parameter sets the file names of the created log files.  The value
        is treated as a <code class="function">strftime</code> pattern,
        so <code class="literal">%</code>-escapes can be used to specify time-varying
        file names.  (Note that if there are
        any time-zone-dependent <code class="literal">%</code>-escapes, the computation
        is done in the zone specified
        by <a class="xref" href="/docs/18/runtime-config-logging.html#GUC-LOG-TIMEZONE">log_timezone</a>.)
        The supported <code class="literal">%</code>-escapes are similar to those
        listed in the Open Group's <a class="ulink" href="https://pubs.opengroup.org/onlinepubs/009695399/functions/strftime.html" target="_top">strftime
        </a> specification.
        Note that the system's <code class="function">strftime</code> is not used
        directly, so platform-specific (nonstandard) extensions do not work.
        The default is <code class="literal">postgresql-%Y-%m-%d_%H%M%S.log</code>.
       </p><p>
        If you specify a file name without escapes, you should plan to
        use a log rotation utility to avoid eventually filling the
        entire disk.  In releases prior to 8.4, if
        no <code class="literal">%</code> escapes were
        present, <span class="productname">PostgreSQL</span> would append
        the epoch of the new log file's creation time, but this is no
        longer the case.
       </p><p>
        If CSV-format output is enabled in <code class="varname">log_destination</code>,
        <code class="literal">.csv</code> will be appended to the timestamped
        log file name to create the file name for CSV-format output.
        (If <code class="varname">log_filename</code> ends in <code class="literal">.log</code>, the suffix is
        replaced instead.)
       </p><p>
        If JSON-format output is enabled in <code class="varname">log_destination</code>,
        <code class="literal">.json</code> will be appended to the timestamped
        log file name to create the file name for JSON-format output.
        (If <code class="varname">log_filename</code> ends in <code class="literal">.log</code>, the suffix is
        replaced instead.)
       </p><p>
        This parameter can only be set in the <code class="filename">postgresql.conf</code>
        file or on the server command line.
       </p>

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:e737c7016fa1b90afdda08b44125bc4a445b8e890f69536b6f3bfd2e4086c8ab

Text language: en · wiki-repair-20261023:e737c7016fa1b90afdda08b44125bc4a445b8e890f69536b6f3bfd2e4086c8ab