简体   繁体   English

Python syslog记录器不能写超过2048个字符

[英]Python syslog logger can't write more than 2048 chars

I'm trying to print some messages to syslog using Python's syslog logger. 我正在尝试使用Python的syslog记录器将一些消息打印到syslog。 Simple logger as described in " How to configure logging to syslog in python? ": 如“ 如何在python中配置到syslog的日志记录? ”中所述的简单记录器:

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. 但是,当我尝试打印一条很长的消息,例如my_logger.debug('<<4000 chars>>') ,它仅打印前2046个字符。 Is there any such known limit in Python? 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. 据我所知,Python支持非常大的字符串输入,并且所有参数都作为引用传递,因此在处理如此大的输入时应该没有任何问题。 Any thoughts? 有什么想法吗?

rsyslogd limits to 2048 bytes per message by default, but you can set it using $MaxMessageSize parameter in /etc/rsyslog.conf : 默认情况下,rsyslogd限制为每条消息2048字节,但是您可以使用/etc/rsyslog.conf $MaxMessageSize参数进行设置:

$MaxMessageSize , default 2k - allows to specify maximum supported message size (both for sending and receiving). $ MaxMessageSize,默认为2k-允许指定最大支持的消息大小(用于发送和接收)。

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

You should use GELF http://www.graylog2.org/about/gelf 您应该使用GELF http://www.graylog2.org/about/gelf

The Graylog Extended Log Format (GELF) avoids the shortcomings of classic plain syslog: Graylog扩展日志格式(GELF)避免了经典普通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? 您可以从中了解更多信息Syslog是否真的有1KB的消息限制?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM