4

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?

Community
  • 1
  • 1
v.rathor
  • 91
  • 2
  • 6
  • 2
    I believe that's a syslog limitation and not a Python one. You could write your own handler that did whatever you wanted. – Katriel Apr 04 '13 at 11:01
  • yeah, that could be the one. Before concluding that I just wanted to strike out python. – v.rathor Apr 04 '13 at 11:36

2 Answers2

2

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

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
xsbrz
  • 135
  • 10
0

You should use GELF http://www.graylog2.org/about/gelf

The Graylog Extended Log Format (GELF) avoids the shortcomings of classic plain syslog:

Limited to length of 1024 byte - Not much space for payloads like backtraces
Unstructured. You can only build a long message string and define priority, severity etc.

You can read more from this Does Syslog really have a 1KB message limit?

Community
  • 1
  • 1
HVNSweeting
  • 2,859
  • 2
  • 35
  • 30