pg_stat_log
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_stat_log | 0.1 | STAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6040 | pg_stat_log | No | Yes | Yes | Yes | No | Yes | - |
| Related | pgelog logerrors pg_sqlog log_fdw pgaudit pgdisablelogerror pg_auth_mon pg_tracing pg_stat_backtrace pgfr_record |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 0.1 | 1817161514 | pg_stat_log | - |
| RPM | PGDG | 0.1 | 1817161514 | pg_stat_log_$v | - |
| DEB | PGDG | 0.1 | 1817161514 | postgresql-$v-stat-log | - |
Install
You can install pg_stat_log directly. First, make sure the PGDG repository is added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
Sources: README, SQL objects, control file
pg_stat_log collects cumulative statistics about PostgreSQL log messages. It hooks into emit_log_hook and counts messages by backend type, database, user, severity, SQLSTATE, and SQLSTATE condition name.
Enable
pg_stat_log requires PostgreSQL 18 or newer and must be preloaded:
Restart PostgreSQL, then create the extension:
View Statistics
The view exposes backend_type, database_oid, database_name, user_oid, user_name, elevel, sqlerrcode, sqlerrcode_name, and count.
Common Queries
Reset And Capacity
pg_stat_log_info() reports max_entries, num_entries, n_dropped, and stats_reset. Increase pg_stat_log.max_entries if n_dropped grows.
Configuration
Settings include pg_stat_log.enabled, pg_stat_log.min_error_level, and pg_stat_log.max_entries.
emit_log_hook only sees messages that reach the server log. log_min_messages therefore acts as a floor for what can be counted.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)