This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: logging.handlers.SysLogHandler with TCP not working on rsyslog5.8
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: matrixise, vinay.sajip, 吴冉波
Priority: normal Keywords:

Created on 2016-06-23 09:04 by 吴冉波, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fail.log 吴冉波, 2016-06-23 09:04 the tcpdump result of sending message with TCP
Messages (4)
msg269112 - (view) Author: 吴冉波 (吴冉波) Date: 2016-06-23 09:04
logging.handlers.SysLogHandler with TCP not working on rsyslog5.8, but newer version rsyslog8.19 is fine.

I use SysLogHandler with TCP to send message to remote rsyslog server failed, but success with bash below: 

echo "<133>$0[$$]: Test syslog message from Netcat" | nc -w1 -t 192.168.1.23 514

this is my script: 
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import logging.handlers
import socket
import syslog

my_logger = logging.getLogger('MyLogger')  # logger is singleton
my_logger.setLevel(logging.DEBUG)

if __name__ == '__main__':

    handler = logging.handlers.SysLogHandler(address=('192.168.1.23', 514), facility="auth", socktype=socket.SOCK_STREAM)
    my_logger.addHandler(handler)
    my_logger.critical('this is critical')

    handler.flush()
    handler.close()
    my_logger.removeHandler(handler)

CentOS version is 6.6
Python version is 2.7.10

This is easy to repeat on my serval CentOS Server. And I attach tcpdump result of script and bash.
msg269118 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-06-23 15:25
If it works fine with rsyslog 8.19 but fails with rsyslog 5.8, what exactly is logging doing wrong? How is rsyslog configured in the two cases? How exactly was the fail.log generated (I know you said tcpdump was used, but can you provide more detail)?

I'm not sure I'll be able to reproduce this, so you may need to identify what you think logging is doing wrong (there have been no changes in SysLogHandler for quite a while, AFAIK).
msg272081 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2016-08-06 09:46
If no more information is available, I will close this issue soon as "not a bug".
msg272082 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2016-08-06 09:52
For me, it's an issue with the management of the protocol in rsyslog and not with the logging library.

You can close the issue.
History
Date User Action Args
2022-04-11 14:58:32adminsetgithub: 71560
2016-08-06 16:25:28vinay.sajipsetstatus: open -> closed
resolution: not a bug
stage: resolved
2016-08-06 09:52:46matrixisesetstatus: pending -> open
nosy: + matrixise
messages: + msg272082

2016-08-06 09:46:40vinay.sajipsetstatus: open -> pending

messages: + msg272081
2016-06-23 15:25:51vinay.sajipsetmessages: + msg269118
2016-06-23 09:04:31吴冉波create