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.

Title: Turn off 'No handlers could be found for logger' message
Type: Stage:
Components: Library (Lib) Versions: Python 2.7
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 "", line 124, in fromstring
    return PatchSet( StringIO(s) )
  File "", line 196, in __init__
  File "", line 512, in parse
    warning("error: no patch data found!")
  File "C:\Python27\lib\logging\", line 1152, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "C:\Python27\lib\logging\", line 1258, in _log
  File "C:\Python27\lib\logging\", line 1268, in handle
  File "C:\Python27\lib\logging\", 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:
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:
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