Menu

Home

Thiemo Kellner

pglogger

pglogger is a logging framework for PostgreSQL. It is inspired by log4j.

Thanks

Thanks is due to all the project members and to the folks developing
PostgreSQL and all its community.
Special tanks to Adrian Klaver, Pavel Stehule and Laurenz Albe for sharing their
insights and precious time. Having said that it feels quite awkward as it is not clear whether other mentions
by name would be appropriate because they shared much of their little spare time.
Please do not be offended.
Thanks to the providers of SourceForge so we can
publish our works to a broader audience. Hopefully it stays clean from add ware
and other nuisances or worse things.

Features

  • Facilitate logging into a log table with information as specified
    below.
  • Facilitate logging output to the standard channel with information as
    specified below.
  • Information elements
    • The logging function/block
    • An arbitrary message
    • Severity
    • Database user that is logging
    • Database user that started the session that is logging
    • Timestamp of the transaction start within the logging takes place
    • ID of the transaction within the logging takes place
    • ID of the process of the logging server
    • Inet adress or the remote partner that is logging
    • Port number or the remote partner that is logging
    • The timestamp of the actual point in time the logging takes place
    • Sequence number to be sure of order of the entries
  • Facilitate a global logging level
  • Facilitate different logging levels for different execution blocks (e. g.
    functions)
  • Distinguish levels such that only messages of defined severity or more
    severe get logged. Logging levels are the same as the ones defined for
    PostgreSQL itself:
    • DEBUG
    • LOG
    • INFO
    • NOTICE
    • WARNING
    • EXCEPTION
  • Protect read of the property table data against unauthorized attempts
  • Optionally output exception stack in case of exception level call

$Header$

Screenshots

Screenshot thumbnail
View LOG_SORTED part 1
Screenshot thumbnail
View LOG_SORTED part 2
Screenshot thumbnail
Table PROPERTY
Screenshot thumbnail
Standard output target

Architecture

Architecture Scalable Vector Graphic

Installation

Full

  1. Provide a fairly recent z-shell (e.g. 5.5.1) or a Windows command line if you do
    not want to run full_install.pg_sql by means of psql against your database
    (only for installation)

  2. Provide a PostgreSQL database ;-) at least of version 13 (the most recent package has been developed against
    version 17.0) with extension dblink installed. Make sure that it has been compiled with LZ4 support. It is required
    for the compression.
    Recommendation is:

    • Connect to template1 with postgres.
    • Execute create extension dblink;.
    • Execute create database <YOUR_APPLICATION_DATABASE>;.
  3. Install pgutils -
    pglogger has been developed against pgutils release 2019-10-08

  4. Create your logging user <LOGUSER> with the create and login privilege onto your application database, e.g
    create role <LOGUSER> with password 'Do change this silly password' createdb login;

  5. Create your logging schema <LOGGER> that is owned by <LOGUSER>. create schema <LOGGER> authorization <LOGUSER>;

  6. Unpack the pglogger package

  7. Adapt tables/PROPERTY.pg_sql(db, user, password), set_parameters.pg_sql,
    full_install.zsh or full_install.bat to your setup

  8. Run full_install.zsh or full_install.bat or full_install.pg_sql against
    your database

  9. As schema owner provide the correct connection string in
    PROPERTY.PROPERTY_VALUE_STRING for PROPERTY.PROPERTY_NAME =
    'DBLINK_CONNECT_STRING'

Delta

Is not supported any more.

$Header$

Usage

  1. Place desired calls to the logging function into your code.
  2. Set appropriate logging level in table LEVELS or globally by one of the
    setter functions or do both things
  3. Make logger administrator change the logging target if desired
  4. Run your code
  5. Check the entries in your logging targets

$Header$

Code Documentation

The documentation of the code is generated by HyperSQL.

Change log

to 202409xx

Improvements

  • Extension uuid-ossp is not needed any longer. It was switched to the core gen_random_uuid function. This also means, that PostgreSQL versions below 13 are not supported any more.
  • Some typos fixed.
  • Improved comments.

Other

The HyperSQL documentation is outdated. Issue [#8] has been opened to eventually migrate to NaturalDocs or similar for HyperSQL requires Python2 which is not supported anymore even by recent Debian and a port to Python3 has never been carried out successfully.

to 20220512

Improvements

  • Improvements on installation description and comments.

to 20191011

Improvements

  • Improvements on documentation especially on installation description.

to 20191008

Improvements

  • Some functions moved to pgutils project.

to 20190510

Bugs

  • The full installation was having permission problems.

Improvements

  • none

to 20181010

Bugs

  • Issue [#4]: Grant problem fixed

Improvements

  • Issue [#5]: View LOG_LAST_TRANSACTION_SORTED introduced

Main Known Issues

  • Asynchronous logging to tables does not work [#1]
  • Provide setter functions for all the predefined properties [#2]
  • Provide getter functions for all the predefined properties but
    DBLINK_CONNECT_STRING (contains the logger user password) [#3]

Issue Tracking

For issue tracking the SourceForge Tracker is employed.

Code Repository

As code repository the Subversion installation of SourceForge is used.

License

pglogger is under the Lesser Gnu Public License v3 (LGPLv3) or later.

Project Members

Project Members:

Miscelaneous

$Header$


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.