homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Turn off 'No handlers could be found for logger' message
Type: Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, techtonik, vinay.sajip
Priority: normal Keywords:

Created on 2012年11月23日 13:53 by techtonik, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (6)
msg176170 - (view) Author: anatoly techtonik (techtonik) Date: 2012年11月23日 13:53
It is very annoying. Take this as an example. 'patch' is a module (library) that is meant to be used from other programs. Therefore it can not (should not) setup handlers for itself.
>>> import patch
>>> patch.PatchSet().parse('7745')
No handlers could be found for logger "patch"
Is it the same for Python 3?
msg176171 - (view) Author: anatoly techtonik (techtonik) Date: 2012年11月23日 14:23
Forgot to mention that bundled NullHandler doesn't work in Python 2.7 and from what I can see it is not covered with tests for this version.
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "patch.py", line 124, in fromstring
 return PatchSet( StringIO(s) )
 File "patch.py", line 196, in __init__
 self.parse(stream)
 File "patch.py", line 512, in parse
 warning("error: no patch data found!")
 File "C:\Python27\lib\logging\__init__.py", line 1152, in warning
 self._log(WARNING, msg, args, **kwargs)
 File "C:\Python27\lib\logging\__init__.py", line 1258, in _log
 self.handle(record)
 File "C:\Python27\lib\logging\__init__.py", line 1268, in handle
 self.callHandlers(record)
 File "C:\Python27\lib\logging\__init__.py", line 1307, in callHandlers
 if record.levelno >= hdlr.level:
AttributeError: type object 'NullHandler' has no attribute 'level'
msg176173 - (view) Author: anatoly techtonik (techtonik) Date: 2012年11月23日 14:29
Nevermind the last message - I was specifying NullHandler as a class, not as an instance.
msg176176 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2012年11月23日 15:28
This is not a valid issue. The approach to use is documented:
http://docs.python.org/2.6/library/logging.html#configuring-logging-for-a-library
http://docs.python.org/2.7/howto/logging.html#configuring-logging-for-a-library 
msg176191 - (view) Author: anatoly techtonik (techtonik) Date: 2012年11月23日 17:20
I'd say this is a pretty valid issue with "won't fix" or "workaround available" resolution.
The question - is the same behavior preserved for Python 3?
msg176200 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2012年11月23日 17:55
Python 3 has exactly the same documentation:
http://docs.python.org/3.3/howto/logging.html#configuring-logging-for-a-library 
History
Date User Action Args
2022年04月11日 14:57:38adminsetgithub: 60743
2012年11月23日 17:55:40amaury.forgeotdarcsetstatus: languishing -> closed

nosy: + amaury.forgeotdarc
messages: + msg176200

resolution: wont fix -> works for me
2012年11月23日 17:20:03techtoniksetstatus: closed -> languishing
resolution: not a bug -> wont fix
messages: + msg176191
2012年11月23日 15:28:48vinay.sajipsetstatus: open -> closed
resolution: not a bug
messages: + msg176176
2012年11月23日 14:29:12techtoniksetmessages: + msg176173
2012年11月23日 14:23:09techtoniksetmessages: + msg176171
2012年11月23日 13:53:28techtonikcreate

AltStyle によって変換されたページ (->オリジナル) /