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: module 'logging' has not attribute 'handlers'
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: sasquatchplatypus, vinay.sajip
Priority: normal Keywords:

Created on 2021-01-06 16:30 by sasquatchplatypus, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg384509 - (view) Author: (sasquatchplatypus) Date: 2021-01-06 16:30
when trying to import a handler from logging.handlers, you have to explicitely import logging.handlers, because trying to get it from logging directly (for example import logging, logging.handlers.RotatingFileHandlers)
raises this error: AttributeError: module 'logging' has no attribute 'handlers'
msg384516 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2021-01-06 17:15
This is not a bug - this is how it is supposed to work. The handlers module isn't automatically loaded; you have to import it. The basic handlers (NullHandler, StreamHandler, FileHandler) are in the logging module - additional handlers are in logging.handlers.
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 87008
2021-01-06 17:15:20vinay.sajipsetstatus: open -> closed
resolution: not a bug
messages: + msg384516

stage: resolved
2021-01-06 16:46:40shihai1991setnosy: + vinay.sajip
2021-01-06 16:38:53sasquatchplatypussettitle: import logging.handlers shows weird behavior -> module 'logging' has not attribute 'handlers'
2021-01-06 16:30:16sasquatchplatypuscreate