Reputation: 27
I am sending syslog on UDP to remotehost its working fine but while i am sending log on tcp then logs are not routing to remote host. I am using syslog server on FreeBSD8.3
can anybody tell me how to send logs to remote host on TCP using syslog server.
Thanks in advance.
Upvotes: 2
Views: 3516
Reputation: 1713
One issue I just ran into while trying to send log messages to an rsyslog server listening on tcp port 10514 was that it requires a last byte of 0A or line feed. I discovered this tcpdumping net cat as that was working but a socket connection was not. For ex the following will not work (the 155 is for local3 + err level) :
import socket
syslogSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
syslogSocket.connect(('127.0.0.1', 10514))
syslogSocket.send('<155>TEST FROM PYTOHON\000')
syslogSocket.close()
But this will work:
import socket
syslogSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
syslogSocket.connect(('127.0.0.1', 10514))
syslogSocket.send('<155>TEST FROM PYTOHON\n')
syslogSocket.close()
To get the 155 check out a page like: http://linux.byexamples.com/archives/412/syslog-sending-log-from-remote-servers-to-syslog-daemon/
Since PRI = (facility << 3) + severity And local3 facility == 19 And severity err = 3
PRI = (19<<3) + 3
152 + 3
155
Upvotes: 0