Search code examples
pythonlogginglimitsyslog

Python syslog logger can't write more than 2048 chars


I'm trying to print some messages to syslog using Python's syslog logger. Simple logger as described in "How to configure logging to syslog in python?":

import logging
import logging.handlers

my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)

handler = logging.handlers.SysLogHandler()

my_logger.addHandler(handler)

my_logger.debug('this is debug')

But when I'm trying to print a very long message like my_logger.debug('<<4000 chars>>'), it is printing only first 2046 chars. Is there any such known limit in Python?

From what I could gather, Python supports a VERY big string input and all the arguments are passed as reference, so it should not be any problem in handling such large input. Any thoughts?


Solution

  • rsyslogd limits to 2048 bytes per message by default, but you can set it using $MaxMessageSize parameter in /etc/rsyslog.conf:

    $MaxMessageSize , default 2k - allows to specify maximum supported message size (both for sending and receiving).

    Reference: http://www.rsyslog.com/doc/v8-stable/configuration/global/index.html