简体   繁体   English

如何从rsyslog消息中删除BOM(字节顺序标记)

[英]How to remove BOM (byte order mark) from rsyslog messages

In my current rsyslog messages, there are a lot BOMs showing up like <feff > in the log messages. 在我当前的rsyslog消息中,在日志消息中显示了许多BOM,例如<feff >。 Is there any way I can get rid of these BOMs in the log messages? 有什么办法可以消除日志消息中的这些BOM? I'm using rsyslog 8.10. 我正在使用rsyslog 8.10。 Any suggestions? 有什么建议么? Thanks in advance. 提前致谢。

I think this might actually be caused by a bug in older versions of Python. 我认为这实际上可能是由旧版Python中的错误引起的。 Do you know if your Python version on the system is up to date? 您知道系统上的Python版本是否最新吗? If not, you might try updating it to whatever the latest Python 2.7 is that you can get for the system. 如果没有,您可以尝试将其更新到可以为系统获取的最新Python 2.7。

Related bug reports: 相关的错误报告:

Short of updating to a new Python 2.7 version, tt seems the only way to work around this is for an older Python 2.7 install is to apply the following patch to the /usr/lib/python2.7/logging/handlers.py file on your system. 缺少更新到新的Python 2.7版本的方法,tt似乎唯一的解决方法是对于较旧的Python 2.7安装是将以下修补程序应用于/usr/lib/python2.7/logging/handlers.py文件。你的系统。

@@ -797,9 +797,10 @@
                                             self.mapPriority(record.levelname))
         # Message is a string. Convert to bytes as required by RFC 5424
         if type(msg) is unicode:
            msg = msg.encode('utf-8')
- if codecs:
- msg = codecs.BOM_UTF8 + msg
+ #if codecs:
+ # msg = codecs.BOM_UTF8 + msg
         msg = prio + msg
         try:
             if self.unixsocket:

For a Python 2.6 system, I think you might instead need the following patch to the /usr/lib/python2.6/logging/handlers.py file on the system. 对于Python 2.6系统,我认为您可能需要对系统上的/usr/lib/python2.6/logging/handlers.py文件进行以下修补。

@@ -821,8 +821,6 @@ class SysLogHandler(logging.Handler):
         # Message is a string. Convert to bytes as required by RFC 5424
         if type(msg) is unicode:
             msg = msg.encode('utf-8')
-            if codecs:
-                msg = codecs.BOM_UTF8 + msg
         msg = prio + msg
         try:
             if self.unixsocket:

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

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