Message269112
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. |
|
Date |
User |
Action |
Args |
2016-06-23 09:04:31 | 吴冉波 | set | recipients:
+ 吴冉波, vinay.sajip |
2016-06-23 09:04:31 | 吴冉波 | set | messageid: <1466672671.84.0.9141309622.issue27373@psf.upfronthosting.co.za> |
2016-06-23 09:04:31 | 吴冉波 | link | issue27373 messages |
2016-06-23 09:04:31 | 吴冉波 | create | |
|