Example of how to use logging for both screen and file
Steve
lonetwin at gmail.com
Wed Oct 27 05:21:44 EDT 2004
Hi list,
Could someone help me figure out what is wrong here ?? I'd like to use
logging to send logs to syslogd as well as a file. The file logging
seems to be fine, but why don't I see anything in '/var/log/messages'
??
======================================
import logging, logging.handlers
def setupLogging():
global flog, slog
flog = logging.getLogger("mylog")
slog = logging.getLogger("mylog.slog")
flog.setLevel(logging.INFO)
slog.setLevel(logging.INFO)
filelog_hdlr = logging.FileHandler('/tmp/mylog')
syslog_hdlr = logging.handlers.SysLogHandler()
flog.addHandler(filelog_hdlr)
slog.addHandler(syslog_hdlr)
setupLogging()
flog.info("##################### foo #####################")
slog.debug("################## bar ####################"")
---------------------------------------------------------------------------------------------------
my syslog.conf says:
*.* /var/log/messages
======================================
Regards
Steve
More information about the Python-list
mailing list