[Tutor] Q2: logging not working as expected

dave selby dave6502 at googlemail.com
Fri Nov 16 22:09:27 CET 2007


I am trying to use the python logging module. At first glance it looks
pretty complicated but having Ggooled a lot I have come up with a
trial script of  ...

logging.config.fileConfig("logging.conf")
logger = logging.getLogger()
logger.critical("Test Message")

Where 'loggin.conf' contains ...

[loggers]
keys=root,hdk1,hkd2

[handlers]
keys=SysLog,hand02

[formatters]
keys=SysLog

[logger_root]
level=NOTSET
handlers=SysLog

[logger_hkd1]
level=DEBUG
propagate=1
qualname=hkd1
handlers=SysLog
channel=hkd1
parent=(root)

[logger_hkd2]
level=DEBUG
propagate=1
qualname=hkd2
handlers=hand02
channel=hkd2
parent=(root)

[handler_hand02]
class=FileHandler
level=DEBUG
formatter=SysLog
args=('python.log', 'w')

[handler_SysLog]
class=handlers.SysLogHandler
level=DEBUG
formatter=SysLog
args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)

[formatter_SysLog]
format=%(filename)s[%(process)d]: %(levelname)s: %(message)s

I was trying to get logging to report to Syslog, that failed so I
changed it to write to a file 'python.log' .  When I execute my test
script 'python.log' appears but contains no messages and no error
messages are generated.

Anybody any ideas as to what I am doing wrong ?

Cheers

Dave

-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


More information about the Tutor mailing list