pgauditlogtofile
pgauditlogtofile
pgauditlogtofile : pgAudit addon to redirect audit log to an independent file
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 7120 | pgauditlogtofile
|
pgauditlogtofile
|
1.8.0 |
SEC
|
PostgreSQL
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-r
|
No
|
Yes
|
Yes
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | pgaudit
pg_auth_mon
logerrors
pg_permissions
login_hook
set_user
pg_drop_events
table_log
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
1.8.0 |
18
17
16
15
14
|
pgauditlogtofile |
- |
| RPM | PGDG
|
1.8.0 |
18
17
16
15
14
|
pgauditlogtofile_$v |
- |
| DEB | PGDG
|
1.8.0 |
18
17
16
15
14
|
postgresql-$v-pgauditlogtofile |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
el8.aarch64
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
el9.x86_64
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
el9.aarch64
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
el10.x86_64
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
el10.aarch64
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
PGDG 1.8.1
|
d12.x86_64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
d12.aarch64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
d13.x86_64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
d13.aarch64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
u22.x86_64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
u22.aarch64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
u24.x86_64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
u24.aarch64
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
PGDG 1.8.0
|
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install pgauditlogtofile; # install via package name, for the active PG version
pig install pgauditlogtofile -v 18; # install for PG 18
pig install pgauditlogtofile -v 17; # install for PG 17
pig install pgauditlogtofile -v 16; # install for PG 16
pig install pgauditlogtofile -v 15; # install for PG 15
pig install pgauditlogtofile -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pgauditlogtofile';Create this extension with:
CREATE EXTENSION pgauditlogtofile;Usage
pgauditlogtofile: Redirect pgAudit logs to an independent file
pgauditlogtofile is an addon to pgAudit that redirects audit log lines to a separate file instead of the PostgreSQL server log, with automatic rotation support.
CREATE EXTENSION pgauditlogtofile;Configuration Parameters
| Parameter | Default | Description |
|---|---|---|
pgaudit.log_format |
csv |
Output format: csv or json |
pgaudit.log_directory |
log |
Directory for audit files (empty disables) |
pgaudit.log_filename |
audit-%Y%m%d_%H%M.log |
Filename pattern (supports time patterns) |
pgaudit.log_file_mode |
0600 |
File permissions for audit logs |
pgaudit.log_rotation_age |
1440 |
Rotation interval in minutes (1 day) |
pgaudit.log_connections |
off |
Log connection events (requires log_connections = on) |
pgaudit.log_disconnections |
off |
Log disconnection events (requires log_disconnections = on) |
pgaudit.log_autoclose_minutes |
0 |
Auto-close file handler after N minutes of inactivity |
pgaudit.log_execution_time |
off |
Measure statement execution time |
pgaudit.log_execution_memory |
off |
Measure memory footprint of statements |
Setup
Add to postgresql.conf:
shared_preload_libraries = 'pgaudit, pgauditlogtofile'
pgaudit.log_directory = 'log'
pgaudit.log_filename = 'audit-%Y%m%d_%H%M.log'
pgaudit.log_rotation_age = 1440Audit entries are written to the separate file while server logs remain clean.
Last updated on