logging package log_test3.py problem

J

j vickroy

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
 
V

Vinay Sajip

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,144
Latest member
KetoBaseReviews
Top