mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
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 inac7c807,bed6ed3,8b76f89and2d77d83for the backend parts, and72b76f7for 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
This commit is contained in:
@@ -4276,7 +4276,7 @@ static struct config_string ConfigureNamesString[] =
|
||||
{"log_destination", PGC_SIGHUP, LOGGING_WHERE,
|
||||
gettext_noop("Sets the destination for server log output."),
|
||||
gettext_noop("Valid values are combinations of \"stderr\", "
|
||||
"\"syslog\", \"csvlog\", and \"eventlog\", "
|
||||
"\"syslog\", \"csvlog\", \"jsonlog\" and \"eventlog\", "
|
||||
"depending on the platform."),
|
||||
GUC_LIST_INPUT
|
||||
},
|
||||
@@ -11752,6 +11752,8 @@ check_log_destination(char **newval, void **extra, GucSource source)
|
||||
newlogdest |= LOG_DESTINATION_STDERR;
|
||||
else if (pg_strcasecmp(tok, "csvlog") == 0)
|
||||
newlogdest |= LOG_DESTINATION_CSVLOG;
|
||||
else if (pg_strcasecmp(tok, "jsonlog") == 0)
|
||||
newlogdest |= LOG_DESTINATION_JSONLOG;
|
||||
#ifdef HAVE_SYSLOG
|
||||
else if (pg_strcasecmp(tok, "syslog") == 0)
|
||||
newlogdest |= LOG_DESTINATION_SYSLOG;
|
||||
|
||||
Reference in New Issue
Block a user