下面是我用来接收syslog并将其附加到文本文件中的脚本:
# Receives packets on udp port 514 and
# writes to syslog.txt
from socket import *
# Set the socket parameters
host = "myhost"
port = 514
buf = 1024
addr = (host,port)
# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)