Python App ouput to syslog server Python App ouput to syslog server unix unix

Python App ouput to syslog server


You can configure the logging module to output to syslog, see http://docs.python.org/library/logging.handlers.html#sysloghandler

Simple example:

from logging.handlers import SysLogHandlerimport logginglogger = logging.getLogger()logger.addHandler(SysLogHandler('/dev/log'))logger.addHandler(logging.FileHandler("filename.log"))logging.warn("Hello world")

The above logs to the local syslog using a Unix domain socket. You can also specify a hostname to log to syslog using UDP. See the docs for more info.