select open change scope Open full search

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

CONFIGURATION / REPORTING AND LOGGING

When logging_collector is enabled, this parameter sets the file names of the created log files.

Type
string
Context
sighup
Measured default
postgresql-%Y-%m-%d_%H%M%S.log
Unit
Metadata snapshot
18

Definition PG 18 manual

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.

Measured default history
Version intervalDefault
9.0 – 19postgresql-%Y-%m-%d_%H%M%S.log
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

log_filename sets the file name pattern for log files. logging_collector expands strftime escapes using log_timezone whenever it opens a new file, so repeating names must be coordinated with rotation and truncation.

log_filename is a SIGHUP-context setting: a configuration reload activates the new server value without a restart; subsequent operations that consult it use the refreshed value.

The active path is composed from log_destination, logging_collector or syslog/eventlog, file naming and permissions, rotation triggers, and external shipping or retention.

Operational considerations

Editing log_filename without reloading configuration and verifying the effective value and subsequent behavior.

Combining incompatible destination, collector, filename, and rotation assumptions and then losing or overwriting logs.

Failing to monitor a full or unwritable log target, which can block logging or database activity depending on the path.

Using a repeating strftime name without matching rotation and truncation policy, causing append growth or overwrite surprises.

Workload guidance

OLAP: Choose a predictable period boundary for large analytical logs and ensure downstream ingestion closes the previous file before the pattern repeats; do not rely on size rotation with a non-unique name.

OLTP: Use a filename pattern whose uniqueness matches rotation policy. If names repeat, combine time-based rotation, log_truncate_on_rotation, and confirmed shipping so a reused name cannot mix periods or overwrite uncollected data.

SMALL: A bounded weekday or date pattern is reasonable only with matching retention and free-space monitoring. Keep enough time components to prevent accidental collisions after restart or manual rotation.

Version history 2
  1. PG 14 → 15changed
  2. PG 9.0 → 9.1changed

Related entries

Further reading

Definition snapshot: english-manuals:cc262f8868bb917a56a16bfd91b… · English manual source