From 72ea7dc222f41ab8246c0aa080d1c1adaf78f4c7 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 26 Feb 2016 22:37:15 -0500 Subject: [PATCH 2/2] Add syslog_split_lines parameter --- doc/src/sgml/config.sgml | 33 +++++++++++++++++++++++++++ src/backend/utils/error/elog.c | 3 ++- src/backend/utils/misc/guc.c | 10 ++++++++ src/backend/utils/misc/postgresql.conf.sample | 1 + src/include/utils/elog.h | 1 + 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 0d1ae4b..eb12cc5 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -4246,6 +4246,39 @@ Where To Log + + syslog_split_lines (boolean) + + syslog_split_lines configuration parameter + + + + + When logging to syslog is enabled, this parameter + determines how messages are delivered to syslog. When on (the + default), messages are split by lines, and long lines are split so + that they will fit into 1024 bytes, which is a typical size limit for + traditional syslog implementations. When off, PostgreSQL server log + messages are delivered to the syslog service as is, and it is up to + the syslog service to cope with the potentially bulky messages. + + + + If syslog is ultimately logging to a text file, then the effect will + be the same either way, and it is best to leave the setting on, since + most syslog implementations either cannot handle large messages or + would need to be specially configured to handle them. But if syslog + is ultimately writing into some other medium, it might be necessary or + more useful to keep messages logically together. + + + + This parameter can only be set in the postgresql.conf + file or on the server command line. + + + + event_source (string) diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 0bc96b4..8c999a7 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -107,6 +107,7 @@ char *Log_line_prefix = NULL; /* format for extra log line info */ int Log_destination = LOG_DESTINATION_STDERR; char *Log_destination_string = NULL; bool syslog_sequence_numbers = true; +bool syslog_split_lines = true; #ifdef HAVE_SYSLOG @@ -1956,7 +1957,7 @@ write_syslog(int level, const char *line) */ len = strlen(line); nlpos = strchr(line, '\n'); - if (len > PG_SYSLOG_LIMIT || nlpos != NULL) + if (syslog_split_lines && (len > PG_SYSLOG_LIMIT || nlpos != NULL)) { int chunk_nr = 0; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index bc8faa9..f5e071d 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1642,6 +1642,16 @@ static struct config_bool ConfigureNamesBool[] = NULL, NULL, NULL }, + { + {"syslog_split_lines", PGC_SIGHUP, LOGGING_WHERE, + gettext_noop("Split messages sent to syslog."), + NULL + }, + &syslog_split_lines, + true, + NULL, NULL, NULL + }, + /* End-of-list marker */ { {NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index a85ba36..89fd8f7 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -359,6 +359,7 @@ #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' #syslog_sequence_numbers = true +#syslog_split_lines = on # This is only relevant when logging to eventlog (win32): #event_source = 'PostgreSQL' diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index bfbcf96..4ab6356 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -397,6 +397,7 @@ extern char *Log_line_prefix; extern int Log_destination; extern char *Log_destination_string; extern bool syslog_sequence_numbers; +extern bool syslog_split_lines; /* Log destination bitmap */ #define LOG_DESTINATION_STDERR 1 -- 2.7.2