Log Formats and Log Retrieval
This page lists the log line formats Managed PostgreSQL accepts, shows what each one looks like, and describes how to read the server log.
Log Line Formats
log_line_prefix is not free-form: the API accepts four values and rejects any other string with
log_line_prefix must be one of the following. A new service uses the first one.
| Value | Fields it emits |
|---|---|
'pid=%p,user=%u,db=%d,app=%a,client=%h ' | process ID, user, database, application, client host |
'pid=%p,user=%u,db=%d,app=%a,client=%h,txid=%x,qid=%Q ' | the same, plus transaction ID and query ID |
'%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' | timestamp, process ID, line number in the session, user, database, application, client host |
'%m [%p] %q[user=%u,db=%d,app=%a] ' | timestamp with milliseconds, process ID, then user, database and application for client sessions only |
The escapes are those of PostgreSQL’s
log_line_prefix ↗.
Timestamps are in GMT.
Sample Lines
Every message returned by exo dbaas logs starts with a sequence number in brackets, for example
[29-1], added before the prefix. The same failed statement, logged with each format:
'pid=%p,user=%u,db=%d,app=%a,client=%h '
[29-1] pid=7230,user=avnadmin,db=defaultdb,app=psql,client=203.0.113.10 ERROR: division by zero
[29-2] pid=7230,user=avnadmin,db=defaultdb,app=psql,client=203.0.113.10 STATEMENT: begin; insert into accounts values (1000,'fmt'); select 1/0;'pid=%p,user=%u,db=%d,app=%a,client=%h,txid=%x,qid=%Q '
[33-1] pid=7268,user=avnadmin,db=defaultdb,app=psql,client=203.0.113.10,txid=1426,qid=-8066023609998936931 ERROR: division by zero
[33-2] pid=7268,user=avnadmin,db=defaultdb,app=psql,client=203.0.113.10,txid=1426,qid=-8066023609998936931 STATEMENT: begin; insert into accounts values (2000,'fmt'); select 1/0;'%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '
[37-1] 2026-11-10 14:12:42 GMT [7294]: [4-1] user=avnadmin,db=defaultdb,app=psql,client=203.0.113.10 ERROR: division by zero
[37-2] 2026-11-10 14:12:42 GMT [7294]: [5-1] user=avnadmin,db=defaultdb,app=psql,client=203.0.113.10 STATEMENT: begin; insert into accounts values (3000,'fmt'); select 1/0;'%m [%p] %q[user=%u,db=%d,app=%a] '
[41-1] 2026-11-10 14:12:47.961 GMT [7327] [user=avnadmin,db=defaultdb,app=psql] ERROR: division by zero
[41-2] 2026-11-10 14:12:47.961 GMT [7327] [user=avnadmin,db=defaultdb,app=psql] STATEMENT: begin; insert into accounts values (4000,'fmt'); select 1/0;Points to weigh when you choose:
- The first three formats show the client address. The
%mformat drops it. - The first format has no timestamp in the message. The
timefield of each entry, and thetimestampfield in OpenSearch, still carry the time. txidis0until a statement is assigned a transaction ID.qidis filled while query identifiers are computed:compute_query_idisautoon a new service, and identifiers appear oncepg_stat_statementsis installed.- Lines from background processes, such as configuration reloads, have empty fields, for example
pid=95,user=,db=,app=,client=in the first format.
Set the Format
The values include their own surrounding single quotes and a trailing space, both part of the
string. Put the setting in a file to avoid shell quoting. Write pg-settings.json:
{
"log_line_prefix": "'%m [%p] %q[user=%u,db=%d,app=%a] '"
}Then apply it:
exo dbaas update SERVICE_NAME -z ZONE -f --pg-settings "$(<pg-settings.json)"Parameters:
SERVICE_NAME: name of the Managed PostgreSQL service.ZONE: zone the service runs in, for examplech-gva-2.
$(<file) is a bash and zsh construct. In other shells, use $(cat pg-settings.json).
The change is applied by a configuration reload, without a restart, within seconds. Confirm it:
SHOW log_line_prefix;Tip
Decide the format before you point a log analyzer at the stream. Lines written before and after a change have different layouts.
Settings That Control What Is Logged
| Setting | Values | In force on a new service |
|---|---|---|
log_min_duration_statement | -1 to 86400000 ms; -1 disables, 0 logs every statement | 1000 |
log_temp_files | -1 to 2147483647 kB; -1 disables, 0 logs every temporary file | 100 |
log_error_verbosity | TERSE, DEFAULT, VERBOSE | default |
log_autovacuum_min_duration | -1 to 2147483647 ms, in the autovacuum group | 1000 |
log_connections and log_disconnections are on, and they are not part of the settings catalog. The platform’s monitoring
user _avnadmin_monitor and the postgres superuser connect every few seconds, so most lines on a
quiet service are their connections and disconnections.
Set the values with exo dbaas update:
exo dbaas update my-postgresql -z ch-gva-2 -f \
--pg-settings='{"log_min_duration_statement":500,"log_temp_files":1024,"log_error_verbosity":"VERBOSE"}'log_autovacuum_min_duration is nested in the autovacuum group:
exo dbaas update my-postgresql -z ch-gva-2 -f \
--pg-settings='{"autovacuum":{"log_autovacuum_min_duration":5000}}'Important
exo dbaas update --pg-settings leaves out keys whose value is 0. Alone, such a key fails with
No data to update the service; nested in a group, it is skipped without an error. Set a 0
with the API instead:
echo '{"pg-settings":{"log_min_duration_statement":0}}' | \
exo api update-dbaas-service-pg my-postgresql -z ch-gva-2A slow statement is logged with its duration:
[41-1] 2026-11-10 14:12:49.346 GMT [7331] [user=avnadmin,db=defaultdb,app=psql] LOG: duration: 1101.890 ms statement: select pg_sleep(1.1), 'slow_fmt_4'For finding slow queries systematically, use pg_stat_statements as described in
Identify slow queries.
Retrieve Logs
exo dbaas logs SERVICE_NAME -z ZONE --limit LIMIT --sort ORDERParameters:
SERVICE_NAME: name of the Managed PostgreSQL service.ZONE: zone the service runs in, for examplech-gva-2.LIMIT: number of entries, from1to500. Without--limit, the command returns 100 entries.ORDER:descfor newest first, which is the default, orasc. Both return the newestLIMITentries;asclists them oldest first.
For example, the last 200 entries in chronological order, messages only:
exo dbaas logs my-postgresql -z ch-gva-2 --limit 200 --sort asc \
--output-template '{{range $l := .Logs}}{{println $l.Message}}{{end}}'Each entry carries time (UTC), node, unit and message. In an output template the fields are
.Time, .Node, .Unit and .Message. The unit is postgresql-18.service on PostgreSQL 18:
PgBouncer lines are not part of the stream, and neither are
pgaudit records. The
stream lags behind the server by up to about a minute.
The equivalent API operation is get-dbaas-service-logs:
echo '{"limit":500,"sort-order":"asc"}' | \
exo api get-dbaas-service-logs my-postgresql -z ch-gva-2Page Through Older Entries
The JSON output carries an opaque offset. Pass it back to get the next older batch:
exo dbaas logs my-postgresql -z ch-gva-2 --limit 500 -O json | jq -r .offsetexo dbaas logs my-postgresql -z ch-gva-2 --limit 500 -o OFFSETParameters:
OFFSET: theoffsetvalue returned by the previous call.
The response also carries the offset of the first entry of the batch, under first_log_offset in
exo dbaas logs -O json output, first-log-offset in the exo api get-dbaas-service-logs
response, and .FirstLogOffset in an output template.
Keep the Logs
exo dbaas logs reads a bounded buffer. To keep and search the log, and to receive pgaudit records,
send it to a Managed OpenSearch service of your organization as described in
Send logs to Managed OpenSearch.
For a system you run yourself, the rsyslog, OpenSearch and Elasticsearch external endpoints are
described in Use External Integrations.