[Tutor] Q2: logging not working as expected

Eric Brunson brunson at brunson.com
Fri Nov 16 22:23:07 CET 2007


I can't get the python 2.5.1 logging module to use your logging.conf, 
can you create a simpler example?

dave selby wrote:
> 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
>
>   



More information about the Tutor mailing list