pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Introduce log_destination=jsonlog
Date: Mon, 17 Jan 2022 01:19:01 +0000
Message-ID: <E1n9Gfl-0006K8-Pp@gemulon.postgresql.org> (raw)

Introduce log_destination=jsonlog

"jsonlog" is a new value that can be added to log_destination to provide
logs in the JSON format, with its output written to a file, making it
the third type of destination of this kind, after "stderr" and
"csvlog".  The format is convenient to feed logs to other applications.
There is also a plugin external to core that provided this feature using
the hook in elog.c, but this had to overwrite the output of "stderr" to
work, so being able to do both at the same time was not possible.  The
files generated by this log format are suffixed with ".json", and use
the same rotation policies as the other two formats depending on the
backend configuration.

This takes advantage of the refactoring work done previously in ac7c807,
bed6ed3, 8b76f89 and 2d77d83 for the backend parts, and 72b76f7 for the
TAP tests, making the addition of any new file-based format rather
straight-forward.

The documentation is updated to list all the keys and the values that
can exist in this new format.  pg_current_logfile() also required a
refresh for the new option.

Author: Sehrope Sarkuni, Michael Paquier
Reviewed-by: Nathan Bossart, Justin Pryzby
Discussion: https://postgr.es/m/CAH7T-aqswBM6JWe4pDehi1uOiufqe06DJWaU5=X7dDLyqUExHg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/dc686681e0799b12c40f44f85fc5bfd7fed4e57f

Modified Files
--------------
doc/src/sgml/config.sgml                      | 223 ++++++++++++++++++-
doc/src/sgml/func.sgml                        |   8 +-
src/backend/postmaster/syslogger.c            | 107 +++++++--
src/backend/utils/adt/misc.c                  |   6 +-
src/backend/utils/error/Makefile              |   3 +-
src/backend/utils/error/elog.c                |  18 ++
src/backend/utils/error/jsonlog.c             | 303 ++++++++++++++++++++++++++
src/backend/utils/misc/guc.c                  |   4 +-
src/backend/utils/misc/postgresql.conf.sample |  13 +-
src/bin/pg_ctl/t/004_logrotate.pl             |  20 +-
src/include/postmaster/syslogger.h            |   1 +
src/include/utils/elog.h                      |   2 +
12 files changed, 660 insertions(+), 48 deletions(-)



Message-ID: <E1n9Gfl-0006K8-Pp@gemulon.postgresql.org>
Permalink:  ../E1n9Gfl-0006K8-Pp@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1n9Gfl-0006K8-Pp@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz
  Subject: Re: pgsql: Introduce log_destination=jsonlog
  In-Reply-To: <E1n9Gfl-0006K8-Pp@gemulon.postgresql.org>
  References: <E1n9Gfl-0006K8-Pp@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox