By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,008 Members | 2,895 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,008 IT Pros & Developers. It's quick & easy.

logging package log_test3.py problem

P: n/a
My system:
MSW XP professional
Python 2.3.3
logging package: 0.4.9.2

My problem:
The log_test3.py script, provided with the logging package distribution,
generates an unexpected message:
No handlers could be found for logger "root"

Here is the complete trace from running the log_test3.py script:

========================================

C:\projects\logging-0.4.9.2\test>log_test3.py
Traceback (most recent call last):
File "C:\Python23\Lib\site-packages\logging\config.py", line 111, in
fileConfig
h = apply(klass, args)
File "C:\Python23\Lib\site-packages\logging\handlers.py", line 559, in
__init__
self._welu.AddSourceToRegistry(appname, dllname, logtype)
File "C:\Python23\Lib\site-packages\win32\lib\win32evtlogutil.py", line
35, in AddSourceToRegistry
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s \\%s" % (eventLogType,
appName))
error: (5, 'RegCreateKey', 'Access is denied.')
---------------------------------------------------
-- Logging to root; messages appear on console only
---------------------------------------------------
No handlers could be found for logger "root"
----------------------------------------------------------------------
-- Logging to log02; messages appear on console and in file python.log
----------------------------------------------------------------------
--------------------------------------------------------------------------
-- Logging to log02.log03; messages appear on console, in file python.log,
-- and at logrecv.py tcp (if running. <= DEBUG messages will not appear).
--------------------------------------------------------------------------
-----------------------------------------------------------------------
-- Logging to log02.log03.log04; messages appear only at logrecv.py udp
-- (if running. <= INFO messages will not appear).
-----------------------------------------------------------------------
--------------------------------------------------------------------
-- Logging to log02.log03.log04.log05.log06; messages appear at
-- logrecv.py udp (if running. < CRITICAL messages will not appear).
--------------------------------------------------------------------
-- All done.

========================================

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"

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
-- jv

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> 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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.