python logging writes an empty file

Ovidiu Deac ovidiudeac at gmail.com
Fri Mar 26 10:29:43 EDT 2010


> You set le level of your handler, but did not set the level of the logger
> itself.
> Replace file.setLevel(logging.INFO) by
> logging.getLogger().setLevel(logging.INFO)
>
> Log events are matched versus the logger level 1st, then the handler level
> (if applicable). Most of the time you don't need to tune your handler
> levels.

Right. Thanks a lot!!!

Now for the second part, any idea why logging.config.fileConfig doesn't work?

Now the logging.conf looks like this:

[formatters]
keys: detailed

[handlers]
keys: console,file

[loggers]
keys: root

[formatter_detailed]
format: %(name)s:%(levelname)s %(module)s:%(lineno)d:  %(message)s

[handler_console]
class: StreamHandler
args: []
formatter: detailed

[handler_file]
class=FileHandler
formatter=detailed
args=('output.log', 'w')
filename=output.log
mode=w

[logger_root]
level: INFO
handlers: file



More information about the Python-list mailing list