Python 如何写 Ubuntu syslog
address='/dev/log' 是关键
import logging from logging.handlers import SysLogHandler logger = logging.getLogger() logger.setLevel(logging.INFO) syslog = SysLogHandler(address='/dev/log') formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s') syslog.setFormatter(formatter) logger.addHandler(syslog)