如何从 rsyslog 消息中删除 BOM(字节顺序标记)
How to remove BOM (byte order mark) from rsyslog messages
在我当前的 rsyslog 消息中,有很多 BOM 显示为 <feff
> 在日志消息中。有什么办法可以去除日志消息中的这些 BOM?我正在使用 rsyslog 8.10。有什么建议么?提前致谢。
我认为这实际上可能是由旧版本 Python 中的错误引起的。您知道系统上的 Python 版本是否是最新的吗?如果没有,您可以尝试将其更新到您可以为系统获得的最新 Python 2.7。
相关错误报告:
- 在发送到 rsyslog 之前将 BOM 预置为 UTF8 消息会导致日志中出现错误字符 http://bugzilla.adiscon.com/show_bug.cgi?id=346
- UTF8 BOM 在使用 rsysolog 时错误地预先添加系统日志消息 http://bugs.python.org/issue15462
- SysLogHandler 在使用 unicode 时发送无效消息
http://bugs.python.org/issue14452
没有更新到新的 Python 2.7 版本,解决这个问题的唯一方法似乎是对较旧的 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:
对于 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:
在我当前的 rsyslog 消息中,有很多 BOM 显示为 <feff
> 在日志消息中。有什么办法可以去除日志消息中的这些 BOM?我正在使用 rsyslog 8.10。有什么建议么?提前致谢。
我认为这实际上可能是由旧版本 Python 中的错误引起的。您知道系统上的 Python 版本是否是最新的吗?如果没有,您可以尝试将其更新到您可以为系统获得的最新 Python 2.7。
相关错误报告:
- 在发送到 rsyslog 之前将 BOM 预置为 UTF8 消息会导致日志中出现错误字符 http://bugzilla.adiscon.com/show_bug.cgi?id=346
- UTF8 BOM 在使用 rsysolog 时错误地预先添加系统日志消息 http://bugs.python.org/issue15462
- SysLogHandler 在使用 unicode 时发送无效消息
http://bugs.python.org/issue14452
没有更新到新的 Python 2.7 版本,解决这个问题的唯一方法似乎是对较旧的 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:
对于 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: