|## Tiny Syslog Server in Python.|
|## This is a tiny syslog server that is able to receive UDP based syslog|
|## entries on a specified port and save them to a file.|
|## That's it... it does nothing else...|
|## There are a few configuration parameters.|
|LOG_FILE = 'youlogfile.log'|
|HOST, PORT = "0.0.0.0", 514|
|# NO USER SERVICEABLE PARTS BELOW HERE...|
|logging.basicConfig(level=logging.INFO, format='%(message)s', datefmt='', filename=LOG_FILE, filemode='a')|
|data = bytes.decode(self.request.strip())|
|socket = self.request|
|print( "%s : " % self.client_address, str(data))|
|if __name__ == "__main__":|
|server = SocketServer.UDPServer((HOST,PORT), SyslogUDPHandler)|
|except (IOError, SystemExit):|
|print ("Crtl+C Pressed. Shutting down.")|
Thanks, I've used it as a syslog frontend to redis.
You can add
It worked very well when I needed a syslog server for some tests. Thanks for sharing.
@maxenc7, seems like the contention is in the implementation of the logging.info() call itself. Nothing I can do there. That said, 1M/s seems a little bit too much for this tiny logger to handle. In fact, seems a lot for anything to handle in that amount of time. You are probably gonna have to use something to load balance this (haproxy or nginx) and then use several backends. This is completely outside the scope of this gist.