Skip to content

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

Type , Valueinteger
Upstream pg_settings type
Context , Valuesighup
Takes effect after configuration reload
Unit , Value
Raw unit
Range , Value0511
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueReporting and Logging / Where to Log
Upstream classification
Latest boot value , Value384
384

Lifecycle

Fact Value
First observed PG9.1
Present in PG9.1–19 Beta 3
Removed in No
Introduction commit 3ec694e17bc0 — 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

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG9.1–19 Beta 3 384 384

How it works

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

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.

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

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

logging_collector · log_destination · log_directory · log_filename · log_rotation_age · log_rotation_size

References