# log_file_mode

> log_file_mode is the PostgreSQL setting that defines the file permissions for log files.
---

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

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `sighup` | Takes effect after configuration reload |
| Unit | — | Raw unit |
| Range | `0` – `511` | 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 | `384` | 384 |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.1 |
| Present in | PG9.1–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`3ec694e17bc0`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=3ec694e17bc01cec4ae2000847f25e3d549888c0) — Add a log_file_mode GUC that allows control of the file permissions set on log files created by the syslogger process. |
| Commit date | 2010-07-16 |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.1–19 Beta 3 | `384` | — | 384 |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

log_file_mode is a chmod-style numeric mode for files newly created by logging_collector. Use a leading zero for customary octal notation: 0640 is not the same numeric value as decimal 640. The setting does not apply to syslog/eventlog output and does not change existing files.

It has SIGHUP context. After a reload, the new mode is used the next time logging_collector creates a file; reloading does not chmod the file that is currently open or historical files.

The effective access boundary also includes the PostgreSQL service account, file group, log_directory ownership and traversal permissions, shipping-agent group membership, and external retention copies. A group-readable mode is safe only when that group is controlled.

## Tuning advice {#tuning-advice}

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

| Workload | Guidance |
| --- | --- |
| OLTP | Choose the least-privileged mode that still lets the approved collector or shipping group read new files. Verify ownership after a real rotation and explicitly remediate existing files if policy changes. |
| OLAP | Analytical logs often contain query text and identifiers, so use the same or stricter mode; larger log volume is not a reason to broaden file access. |
| Small nodes | Keep 0600 unless a controlled local group must ship logs; if 0640 is used, audit group membership and directory permissions rather than making files world-readable. |
{.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 | `0640` | different | `'0640'` |
| OLAP | `0640` | different | `'0640'` |
| CRIT | `0640` | different | `'0640'` |
| TINY | `0640` | different | `'0640'` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.1–19 Beta 3 = 0640 (dcs); OLAP: PG9.1–19 Beta 3 = 0640 (dcs); CRIT: PG9.1–19 Beta 3 = 0640 (dcs); TINY: PG9.1–19 Beta 3 = 0640 (dcs). Advice, pending human review — Editorial inference: 0640 keeps log files private from other users while allowing an operational group to read and ship them.

## Common pitfalls {#common-pitfalls}

- Editing log_file_mode 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.
- Writing 640 instead of octal 0640 and producing a different numeric permission mode.

## Related parameters {#related-parameters}

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

## References {#references}

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