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: Logger with a custom class breaks on copy
Type: crash Stage:
Components: Library (Lib) Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, govinda18
Priority: normal Keywords:

Created on 2022-03-08 12:45 by govinda18, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg414750 - (view) Author: Govinda Totla (govinda18) Date: 2022-03-08 12:45
The logging module allows you set a custom Logger class as the default logger. However, this breaks when we try to copy the logger which was created before setting the logger class

```
import copy
import logging

# Some module we don't control
oldLogger = logging.getLogger("abc")

# Some module where we want to change over to custom logging
class MyLogger(logging.Logger):
    pass

# Override the manager, root, etc., so everything uses our class
logging.setLoggerClass(MyLogger)
logging.root = root = MyLogger("", logging.WARNING)
logging.Logger.manager = logging.Manager(root)

newLogger = logging.getLogger("def")

# Later on this happens, which internally calls __reduce__
copy.deepcopy(oldLogger)
```
msg414786 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2022-03-09 07:11
In what way does it break? You haven't shown an error.

Why are you deepcopying the logger?
History
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91113
2022-03-09 07:11:41eric.smithsetnosy: + eric.smith
messages: + msg414786
2022-03-08 12:45:10govinda18create