pgelog

pgelog

pgelog : Extended logging via pseudo-autonomous transactions

Overview

ID Extension Package Version Category License Language
5870
pgelog
pgelog
1.0.2
ADMIN
PostgreSQL
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----d--
No
No
No
Yes
no
no
Relationships
Requires
dblink
pg_variables
See Also
table_log
pgaudit
logerrors
dblink

Requires the dblink extension at runtime in addition to pg_variables.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0.2
18
17
16
15
14
pgelog dblink, pg_variables
RPM
PIGSTY
1.0.2
18
17
16
15
14
pgelog_$v postgresql$v-contrib, pg_variables_$v
DEB
PIGSTY
1.0.2
18
17
16
15
14
postgresql-$v-pgelog postgresql-$v-pg-variables
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
el8.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
el9.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
el9.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
el10.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
el10.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
d12.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
d12.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
d13.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
d13.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u22.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u22.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u24.x86_64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
u24.aarch64
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
PIGSTY 1.0.2
Package Version OS ORG SIZE File URL
pgelog_18 1.0.2 el8.x86_64 pigsty 15.7 KiB pgelog_18-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_18 1.0.2 el8.aarch64 pigsty 15.7 KiB pgelog_18-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_18 1.0.2 el9.x86_64 pigsty 15.6 KiB pgelog_18-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_18 1.0.2 el9.aarch64 pigsty 15.5 KiB pgelog_18-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_18 1.0.2 el10.x86_64 pigsty 15.7 KiB pgelog_18-1.0.2-1PIGSTY.el10.noarch.rpm
pgelog_18 1.0.2 el10.aarch64 pigsty 15.7 KiB pgelog_18-1.0.2-1PIGSTY.el10.noarch.rpm
postgresql-18-pgelog 1.0.2 d12.x86_64 pigsty 9.7 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgelog 1.0.2 d12.aarch64 pigsty 9.7 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgelog 1.0.2 d13.x86_64 pigsty 9.7 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~trixie_amd64.deb
postgresql-18-pgelog 1.0.2 d13.aarch64 pigsty 9.7 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~trixie_arm64.deb
postgresql-18-pgelog 1.0.2 u22.x86_64 pigsty 9.9 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~jammy_amd64.deb
postgresql-18-pgelog 1.0.2 u22.aarch64 pigsty 9.9 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~jammy_arm64.deb
postgresql-18-pgelog 1.0.2 u24.x86_64 pigsty 9.9 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~noble_amd64.deb
postgresql-18-pgelog 1.0.2 u24.aarch64 pigsty 9.9 KiB postgresql-18-pgelog_1.0.2-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgelog_17 1.0.2 el8.x86_64 pigsty 15.7 KiB pgelog_17-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_17 1.0.2 el8.aarch64 pigsty 15.7 KiB pgelog_17-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_17 1.0.2 el9.x86_64 pigsty 15.6 KiB pgelog_17-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_17 1.0.2 el9.aarch64 pigsty 15.5 KiB pgelog_17-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_17 1.0.2 el10.x86_64 pigsty 15.7 KiB pgelog_17-1.0.2-1PIGSTY.el10.noarch.rpm
pgelog_17 1.0.2 el10.aarch64 pigsty 15.7 KiB pgelog_17-1.0.2-1PIGSTY.el10.noarch.rpm
postgresql-17-pgelog 1.0.2 d12.x86_64 pigsty 9.7 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-17-pgelog 1.0.2 d12.aarch64 pigsty 9.7 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-17-pgelog 1.0.2 d13.x86_64 pigsty 9.7 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~trixie_amd64.deb
postgresql-17-pgelog 1.0.2 d13.aarch64 pigsty 9.7 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~trixie_arm64.deb
postgresql-17-pgelog 1.0.2 u22.x86_64 pigsty 9.9 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~jammy_amd64.deb
postgresql-17-pgelog 1.0.2 u22.aarch64 pigsty 9.9 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~jammy_arm64.deb
postgresql-17-pgelog 1.0.2 u24.x86_64 pigsty 9.9 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~noble_amd64.deb
postgresql-17-pgelog 1.0.2 u24.aarch64 pigsty 9.9 KiB postgresql-17-pgelog_1.0.2-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgelog_16 1.0.2 el8.x86_64 pigsty 15.7 KiB pgelog_16-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_16 1.0.2 el8.aarch64 pigsty 15.7 KiB pgelog_16-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_16 1.0.2 el9.x86_64 pigsty 15.6 KiB pgelog_16-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_16 1.0.2 el9.aarch64 pigsty 15.5 KiB pgelog_16-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_16 1.0.2 el10.x86_64 pigsty 15.7 KiB pgelog_16-1.0.2-1PIGSTY.el10.noarch.rpm
pgelog_16 1.0.2 el10.aarch64 pigsty 15.7 KiB pgelog_16-1.0.2-1PIGSTY.el10.noarch.rpm
postgresql-16-pgelog 1.0.2 d12.x86_64 pigsty 9.7 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-16-pgelog 1.0.2 d12.aarch64 pigsty 9.7 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-16-pgelog 1.0.2 d13.x86_64 pigsty 9.7 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~trixie_amd64.deb
postgresql-16-pgelog 1.0.2 d13.aarch64 pigsty 9.7 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~trixie_arm64.deb
postgresql-16-pgelog 1.0.2 u22.x86_64 pigsty 9.9 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~jammy_amd64.deb
postgresql-16-pgelog 1.0.2 u22.aarch64 pigsty 9.9 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~jammy_arm64.deb
postgresql-16-pgelog 1.0.2 u24.x86_64 pigsty 9.9 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~noble_amd64.deb
postgresql-16-pgelog 1.0.2 u24.aarch64 pigsty 9.9 KiB postgresql-16-pgelog_1.0.2-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgelog_15 1.0.2 el8.x86_64 pigsty 15.7 KiB pgelog_15-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_15 1.0.2 el8.aarch64 pigsty 15.7 KiB pgelog_15-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_15 1.0.2 el9.x86_64 pigsty 15.6 KiB pgelog_15-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_15 1.0.2 el9.aarch64 pigsty 15.5 KiB pgelog_15-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_15 1.0.2 el10.x86_64 pigsty 15.7 KiB pgelog_15-1.0.2-1PIGSTY.el10.noarch.rpm
pgelog_15 1.0.2 el10.aarch64 pigsty 15.7 KiB pgelog_15-1.0.2-1PIGSTY.el10.noarch.rpm
postgresql-15-pgelog 1.0.2 d12.x86_64 pigsty 9.7 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-15-pgelog 1.0.2 d12.aarch64 pigsty 9.7 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-15-pgelog 1.0.2 d13.x86_64 pigsty 9.7 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~trixie_amd64.deb
postgresql-15-pgelog 1.0.2 d13.aarch64 pigsty 9.7 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~trixie_arm64.deb
postgresql-15-pgelog 1.0.2 u22.x86_64 pigsty 9.9 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~jammy_amd64.deb
postgresql-15-pgelog 1.0.2 u22.aarch64 pigsty 9.9 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~jammy_arm64.deb
postgresql-15-pgelog 1.0.2 u24.x86_64 pigsty 9.9 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~noble_amd64.deb
postgresql-15-pgelog 1.0.2 u24.aarch64 pigsty 9.9 KiB postgresql-15-pgelog_1.0.2-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgelog_14 1.0.2 el8.x86_64 pigsty 15.7 KiB pgelog_14-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_14 1.0.2 el8.aarch64 pigsty 15.7 KiB pgelog_14-1.0.2-1PIGSTY.el8.noarch.rpm
pgelog_14 1.0.2 el9.x86_64 pigsty 15.6 KiB pgelog_14-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_14 1.0.2 el9.aarch64 pigsty 15.5 KiB pgelog_14-1.0.2-1PIGSTY.el9.noarch.rpm
pgelog_14 1.0.2 el10.x86_64 pigsty 15.7 KiB pgelog_14-1.0.2-1PIGSTY.el10.noarch.rpm
pgelog_14 1.0.2 el10.aarch64 pigsty 15.7 KiB pgelog_14-1.0.2-1PIGSTY.el10.noarch.rpm
postgresql-14-pgelog 1.0.2 d12.x86_64 pigsty 9.7 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~bookworm_amd64.deb
postgresql-14-pgelog 1.0.2 d12.aarch64 pigsty 9.7 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~bookworm_arm64.deb
postgresql-14-pgelog 1.0.2 d13.x86_64 pigsty 9.7 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~trixie_amd64.deb
postgresql-14-pgelog 1.0.2 d13.aarch64 pigsty 9.7 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~trixie_arm64.deb
postgresql-14-pgelog 1.0.2 u22.x86_64 pigsty 9.8 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~jammy_amd64.deb
postgresql-14-pgelog 1.0.2 u22.aarch64 pigsty 9.8 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~jammy_arm64.deb
postgresql-14-pgelog 1.0.2 u24.x86_64 pigsty 9.9 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~noble_amd64.deb
postgresql-14-pgelog 1.0.2 u24.aarch64 pigsty 9.9 KiB postgresql-14-pgelog_1.0.2-1PIGSTY~noble_arm64.deb

Source

pig build pkg pgelog;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgelog;		# install via package name, for the active PG version

pig install pgelog -v 18;   # install for PG 18
pig install pgelog -v 17;   # install for PG 17
pig install pgelog -v 16;   # install for PG 16
pig install pgelog -v 15;   # install for PG 15
pig install pgelog -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pgelog CASCADE; -- requires dblink, pg_variables

Usage

Syntax:

CREATE EXTENSION IF NOT EXISTS dblink;
CREATE EXTENSION IF NOT EXISTS pg_variables;
CREATE EXTENSION pgelog;
SELECT pgelog_to_log('SQL', 'standalone', 'Test of logging by pgelog', '1');

Source: README

pgelog writes log records into PostgreSQL tables using pseudo-autonomous transactions implemented through dblink. The key goal is that log entries survive even when the caller’s main transaction rolls back.

Prerequisites

The README requires:

  • PostgreSQL 11 or newer
  • dblink
  • pg_variables
  • local passwordless dblink access, typically via a peer local entry in pg_hba.conf

It also warns that each session may open one extra connection for dblink, so max_connections should be sized accordingly.

Objects

The extension creates:

  • pgelog_params for configuration
  • pgelog_logs as the base log table
  • pgelog_vw_logs as a log view with timing information

The log table/view stores fields such as timestamp, log type, source function, phase, message text, transaction id, SQLSTATE, SQLERRM, and connection name.

Basic Logging

Write a log entry:

SELECT pgelog_to_log('SQL', 'standalone', 'Test of logging by pgelog', '1');

Read the latest log:

SELECT log_stamp, log_info
FROM pgelog_logs
ORDER BY log_stamp DESC
LIMIT 1;

PL/pgSQL Exception Logging

The README includes a larger PL/pgSQL example that catches exceptions, collects diagnostics, writes a FAIL log entry through pgelog_to_log(...), and then re-raises the exception. This is the main pattern for capturing rollback-resistant failure logs.

Configuration

Configuration parameters are managed with:

SELECT pgelog_get_param('pgelog_ttl_minutes');
SELECT pgelog_set_param('pgelog_ttl_minutes', '2880');

The README documents pgelog_ttl_minutes and other parameters through the pgelog_params table and helper functions.

Last updated on