Skip to content

Commit fc201df

Browse files
committed
Add syslog_split_messages parameter
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
1 parent f4c454e commit fc201df

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

doc/src/sgml/config.sgml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4333,6 +4333,39 @@ local0.* /var/log/postgresql
43334333
</listitem>
43344334
</varlistentry>
43354335

4336+
<varlistentry id="guc-syslog-split-messages" xreflabel="syslog_split_messages">
4337+
<term><varname>syslog_split_messages</varname> (<type>boolean</type>)
4338+
<indexterm>
4339+
<primary><varname>syslog_split_messages</> configuration parameter</primary>
4340+
</indexterm>
4341+
</term>
4342+
<listitem>
4343+
<para>
4344+
When logging to <application>syslog</> is enabled, this parameter
4345+
determines how messages are delivered to syslog. When on (the
4346+
default), messages are split by lines, and long lines are split so
4347+
that they will fit into 1024 bytes, which is a typical size limit for
4348+
traditional syslog implementations. When off, PostgreSQL server log
4349+
messages are delivered to the syslog service as is, and it is up to
4350+
the syslog service to cope with the potentially bulky messages.
4351+
</para>
4352+
4353+
<para>
4354+
If syslog is ultimately logging to a text file, then the effect will
4355+
be the same either way, and it is best to leave the setting on, since
4356+
most syslog implementations either cannot handle large messages or
4357+
would need to be specially configured to handle them. But if syslog
4358+
is ultimately writing into some other medium, it might be necessary or
4359+
more useful to keep messages logically together.
4360+
</para>
4361+
4362+
<para>
4363+
This parameter can only be set in the <filename>postgresql.conf</>
4364+
file or on the server command line.
4365+
</para>
4366+
</listitem>
4367+
</varlistentry>
4368+
43364369
<varlistentry id="guc-event-source" xreflabel="event_source">
43374370
<term><varname>event_source</varname> (<type>string</type>)
43384371
<indexterm>

src/backend/utils/error/elog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ char *Log_line_prefix = NULL; /* format for extra log line info */
107107
int Log_destination = LOG_DESTINATION_STDERR;
108108
char *Log_destination_string = NULL;
109109
bool syslog_sequence_numbers = true;
110+
bool syslog_split_messages = true;
110111

111112
#ifdef HAVE_SYSLOG
112113

@@ -1966,7 +1967,7 @@ write_syslog(int level, const char *line)
19661967
*/
19671968
len = strlen(line);
19681969
nlpos = strchr(line, '\n');
1969-
if (len > PG_SYSLOG_LIMIT || nlpos != NULL)
1970+
if (syslog_split_messages && (len > PG_SYSLOG_LIMIT || nlpos != NULL))
19701971
{
19711972
int chunk_nr = 0;
19721973

src/backend/utils/misc/guc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,16 @@ static struct config_bool ConfigureNamesBool[] =
16421642
NULL, NULL, NULL
16431643
},
16441644

1645+
{
1646+
{"syslog_split_messages", PGC_SIGHUP, LOGGING_WHERE,
1647+
gettext_noop("Split messages sent to syslog by lines and to fit into 1024 bytes."),
1648+
NULL
1649+
},
1650+
&syslog_split_messages,
1651+
true,
1652+
NULL, NULL, NULL
1653+
},
1654+
16451655
/* End-of-list marker */
16461656
{
16471657
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL

src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@
359359
#syslog_facility = 'LOCAL0'
360360
#syslog_ident = 'postgres'
361361
#syslog_sequence_numbers = on
362+
#syslog_split_messages = on
362363

363364
# This is only relevant when logging to eventlog (win32):
364365
#event_source = 'PostgreSQL'

src/include/utils/elog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ extern char *Log_line_prefix;
398398
extern int Log_destination;
399399
extern char *Log_destination_string;
400400
extern bool syslog_sequence_numbers;
401+
extern bool syslog_split_messages;
401402

402403
/* Log destination bitmap */
403404
#define LOG_DESTINATION_STDERR 1

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy