pglog
pglog · PostgreSQL log via SQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100458 | pglog | pglog | 1.0 | FDW | PostgreSQL | C |
Usage
Sources:
- Official README
- Official control file
- Official installation SQL
- Official logger implementation
- Official spool reader
pglog is a PostgreSQL 9.3-era proof of concept that captures messages through an error hook, appends them to its own spool files, and exposes those files through a read-only foreign table. It is separate from PostgreSQL’s normal logging collector and should not replace supported log shipping or observability pipelines.
Core Workflow
Preload the library, choose a server-local spool directory, and restart PostgreSQL before installing the SQL objects.
The pglog foreign table uses a CSV-log-shaped schema containing connection, statement, error, and application fields. Queries scan spool files from the configured directory; the wrapper does not push filters down or collect foreign-table statistics.
Configuration and Objects
pglog.directoryis relative toPGDATAunless an absolute path is supplied; its default ispglog_spool.pglog.min_messagessets the minimum captured severity and defaults toWARNING.pglog.rotation_agecontrols time-based file rotation in minutes;0disables rotation.pglog_serverand thepglogforeign table are created by the extension.pglog_severityis the enum used for severity values.
Operational Boundaries
The reviewed 1.0 source does not serialize append operations across PostgreSQL backends, so concurrent messages can interleave or corrupt records. Rotation creates new files but does not remove old ones. The reader opens at most 16 directory entries in filesystem order and does not isolate the current database.
Log rows can contain statements, details, user names, host data, and application text from multiple databases. Grant access narrowly and protect the spool directory as sensitive data. Because the code targets obsolete PostgreSQL APIs and has no current compatibility statement, validate it only on an isolated test build; prefer maintained PostgreSQL logging and collection mechanisms for operational use.