# log_filename

> log_filename is the PostgreSQL setting that defines the file name pattern for log files.
---

> [!NOTE]
> **Fact — official short description:** “Sets the file name pattern for log files.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `string` | Upstream pg_settings type |
| Context | `sighup` | Takes effect after configuration reload |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Reporting and Logging / Where to Log | Upstream classification |
| Latest boot value | `postgresql-%Y-%m-%d_%H%M%S.log` | postgresql-%Y-%m-%d_%H%M%S.log |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `postgresql-%Y-%m-%d_%H%M%S.log` | — | postgresql-%Y-%m-%d_%H%M%S.log |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

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.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| 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. |
| 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. |
| Small nodes | 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. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | `postgresql-%a.log` | different | `'postgresql-%a.log'` |
| OLAP | `postgresql-%a.log` | different | `'postgresql-%a.log'` |
| CRIT | `postgresql-%a.log` | different | `'postgresql-%a.log'` |
| TINY | `postgresql-%a.log` | different | `'postgresql-%a.log'` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = postgresql-%a.log (dcs); OLAP: PG9.0–19 Beta 3 = postgresql-%a.log (dcs); CRIT: PG9.0–19 Beta 3 = postgresql-%a.log (dcs); TINY: PG9.0–19 Beta 3 = postgresql-%a.log (dcs). Advice, pending human review — Editorial inference: A weekday filename creates a predictable seven-name cycle intended to work with daily rotation and truncation.

## Common pitfalls {#common-pitfalls}

- 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.

## Related parameters {#related-parameters}

[`logging_collector`](/parameters/logging-collector/) · [`log_destination`](/parameters/log-destination/) · [`log_directory`](/parameters/log-directory/) · [`log_rotation_age`](/parameters/log-rotation-age/) · [`log_rotation_size`](/parameters/log-rotation-size/)

## References {#references}

- [PostgreSQL 19 Beta 3 — log_filename](https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-FILENAME)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
