logging package log_test3.py problem

Vinay Sajip vinay_sajip at yahoo.co.uk
Tue Aug 24 10:05:50 EDT 2004


> I expect the Windows NT EventLog handler to fail since I am running under an
> account that does not have Windows Registry update privileges.
> 
> However, I did not expect to see the  message:
> 
> No handlers could be found for logger "root"

This appears to be a bug in fileConfig exception handling. I'll look
into it.

> Also, I have not been able to get a demo script to work that uses
> logging.config.fileConfig with custom handlers I have written.  Is this
> permissable?  If so, how?  Here is a sample error I'm seeing:
> 
> NameError: name 'Details_Log' is not defined

If your custom handler Details_Log is defined in module "mymodule"
then in the config file, name the handler as e.g.
mymodule.Details_Log. Then, do

import logging
import mymodule

logging.mymodule = mymodule

Then fileConfig() should work. The reason for all this is that
fileConfig evaluates the string "mymodule.Details_Log" in the
namespace of the logging module. By adding the "logging.mymodule =
mymodule" line, you allow logging to know about the "mymodule" module.

Best regards


Vinay Sajip



More information about the Python-list mailing list