diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2016-03-15 22:48:53 -0400 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2016-03-16 23:21:44 -0400 |
commit | fc201dfd95059fd2fef9862a2fd09cfab42c9bf7 (patch) | |
tree | 4950ae7c748f05a09a9760de9956e2547c0bd84e | |
parent | f4c454e9ba5262c5614c7637983c83b8c327e231 (diff) | |
download | postgresql-fc201dfd95059fd2fef9862a2fd09cfab42c9bf7.tar.gz postgresql-fc201dfd95059fd2fef9862a2fd09cfab42c9bf7.zip |
Add syslog_split_messages parameter
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
-rw-r--r-- | doc/src/sgml/config.sgml | 33 | ||||
-rw-r--r-- | src/backend/utils/error/elog.c | 3 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 10 | ||||
-rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 1 | ||||
-rw-r--r-- | src/include/utils/elog.h | 1 |
5 files changed, 47 insertions, 1 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 34dad867b2e..7695ec186e9 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -4333,6 +4333,39 @@ local0.* /var/log/postgresql </listitem> </varlistentry> + <varlistentry id="guc-syslog-split-messages" xreflabel="syslog_split_messages"> + <term><varname>syslog_split_messages</varname> (<type>boolean</type>) + <indexterm> + <primary><varname>syslog_split_messages</> configuration parameter</primary> + </indexterm> + </term> + <listitem> + <para> + When logging to <application>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. + </para> + + <para> + 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. + </para> + + <para> + This parameter can only be set in the <filename>postgresql.conf</> + file or on the server command line. + </para> + </listitem> + </varlistentry> + <varlistentry id="guc-event-source" xreflabel="event_source"> <term><varname>event_source</varname> (<type>string</type>) <indexterm> diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 88421c72a2a..458f3aa2b65 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_messages = true; #ifdef HAVE_SYSLOG @@ -1966,7 +1967,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_messages && (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 eb2b487acfa..a325943321b 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_messages", PGC_SIGHUP, LOGGING_WHERE, + gettext_noop("Split messages sent to syslog by lines and to fit into 1024 bytes."), + NULL + }, + &syslog_split_messages, + 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 08fc668dff4..773b4e8a4fc 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 = on +#syslog_split_messages = 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 e245b2ee5f8..901651ff5e9 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -398,6 +398,7 @@ extern char *Log_line_prefix; extern int Log_destination; extern char *Log_destination_string; extern bool syslog_sequence_numbers; +extern bool syslog_split_messages; /* Log destination bitmap */ #define LOG_DESTINATION_STDERR 1 |