Add syslog_split_messages parameter
authorPeter Eisentraut
Wed, 16 Mar 2016 02:48:53 +0000 (22:48 -0400)
committerPeter Eisentraut
Thu, 17 Mar 2016 03:21:44 +0000 (23:21 -0400)
Reviewed-by: Andreas Karlsson
doc/src/sgml/config.sgml
src/backend/utils/error/elog.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample
src/include/utils/elog.h

index 34dad867b2e5bf950e3dd608ca23645834d25f4e..7695ec186e9217f439dc2d8ae380c8d32384ae81 100644 (file)
@@ -4333,6 +4333,39 @@ local0.*    /var/log/postgresql
       
      
 
+     
+      syslog_split_messages (boolean)
+      
+       syslog_split_messages 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)
       
index 88421c72a2a4fdebe5282b99e66d5620bdeefe56..458f3aa2b653b8b6f91742ede47253f8b2330bb9 100644 (file)
@@ -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;
 
index eb2b487acfa0fba0207c371bddca921b9a43ca02..a325943321b54c918d5616edc3b925f68436df6f 100644 (file)
@@ -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
index 08fc668dff474de4e91f858f766d05e4368b1db9..773b4e8a4fce306427aa80fc1147d45d9b256799 100644 (file)
 #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'
index e245b2ee5f8c1ea8ded384145eb79969b61299ea..901651ff5e9aa7ba25d2bd0cd4fd1a7af5613764 100644 (file)
@@ -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