Parameter · Reporting and Logging / What to Log
application_name
Sets the application name to be reported in statistics and logs.
- Default:
'' (empty) - Type: string
- Applies: Session (any user)
In plain words
A short name that a program announces when it connects, such as psql or billing-api. It shows up in pg_stat_activity and can be printed in every log line, so you can tell which application ran which query.
The client chooses it (usually in the connection string), and can change it at any time with SET.
For DBAs and operators
Set via the connection string (application_name=billing-api), the PGAPPNAME environment variable, driver options (JDBC ApplicationName), or SET application_name. Limited to 63 bytes (longer values are truncated) and to printable ASCII; other characters are replaced with C-style hexadecimal escapes. libpq's fallback_application_name lets a program supply a default that the user can override (psql uses psql).
Where it appears: pg_stat_activity.application_name, %a in log_line_prefix, the CSV/JSON logs, the log_connections "authorized" line. The ps title is not affected. For replication it is how a standby is matched against synchronous_standby_names (set it in primary_conninfo; it defaults to cluster_name or walreceiver).
SELECT application_name, state, count(*)
FROM pg_stat_activity GROUP BY 1, 2 ORDER BY 3 DESC;Support tip: ask customers to set it per service; it turns "something is holding locks" into "the nightly-export job is holding locks". Connection poolers in transaction mode may show the pooler's name instead unless they pass it through.
How to change it
Any user can change it for their session with SET.
See it in context
Client backend Cumulative statistics Synchronous replication
Related parameters
log_line_prefix log_connections cluster_name synchronous_standby_names