select open change scope Open full search

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

CONFIGURATION / REPORTING AND LOGGING

On Unix systems this parameter sets the permissions for log files when logging_collector is enabled.

Type
integer
Context
sighup
Measured default
384
Unit
Metadata snapshot
18

Definition PG 18 manual

On Unix systems this parameter sets the permissions for log files when logging_collector is enabled. (On Microsoft Windows this parameter is ignored.) The parameter value is expected to be a numeric mode specified in the format accepted by the chmod and umask system calls. (To use the customary octal format the number must start with a 0 (zero).)

The default permissions are 0600, meaning only the server owner can read or write the log files. The other commonly useful setting is 0640, allowing members of the owner's group to read the files. Note however that to make use of such a setting, you'll need to alter log_directory to store the files somewhere outside the cluster data directory. In any case, it's unwise to make the log files world-readable, since they might contain sensitive data.

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

Measured default history
Version intervalDefault
9.1 – 19384
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_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.

Operational considerations

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.

Workload guidance

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.

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.

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

Version history 1
  1. PG 9.0 → 9.1added

Related entries

Further reading

Definition snapshot: english-manuals:62129ef27be2da5170aa906ad3e… · English manual source