Parameter · Reporting and Logging / What to Log
log_line_prefix
Controls information prefixed to each log line. An empty string means no prefix.
- Default:
%m [%p] - Type: string
- Applies: Reload
In plain words
The text put in front of every line in the plain-text log. Escapes like %m (time), %p (process ID), %u (user) and %d (database) are replaced with real values, so each message says when, where and for whom it happened.
The default %m [%p] is minimal; most production setups add at least user, database and application.
For DBAs and operators
Escapes: %a application, %u user, %d database, %r host(port), %h host, %L local address, %b backend type, %p PID, %P parallel leader PID, %t/%m/%n time (seconds / ms / epoch), %Q query ID, %i command tag, %e SQLSTATE, %c session ID, %l line number in session, %s session start, %v virtual xid, %x xid, %q stop here for non-session processes, %% a percent sign. Padding like %-10u is allowed.
A real line with a long prefix (18.6):
2026-10-22 15:37:15.180 UTC [5446] postgres@postgres app=billing-api client=localhost,localhost(53884) xid=0 vxid=18/2 sess=6ada2dab.1546 line=1 22012 tag=SELECT b=client backend Q=0 % ERROR: division by zeroA good general-purpose value, compatible with pgBadger:
log_line_prefix = '%m [%p] %q%u@%d app=%a client=%h 'Tips: always end with a space; use %q so background-process lines (checkpointer, autovacuum launcher) do not get empty @ fields; %Q is 0 unless compute_query_id is active (it is with pg_stat_statements loaded) and lets you join log lines to pg_stat_statements.queryid; %c + %l uniquely order lines of a session. The prefix is not used for csvlog/jsonlog (all fields are always there) and only changeable by reload, not per session.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then run SELECT pg_reload_conf().
See it in context
Related parameters
log_destination application_name log_timezone log_hostname compute_query_id log_error_verbosity