Skip to content

set_logging stomps over root logging handlers #6278

@robby-d

Description

@robby-d

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Other

Bug

I'm wondering if there is a good reason why set_logging deletes root logging handlers (see

yolov5/utils/general.py

Lines 49 to 50 in b4a29b5

for h in logging.root.handlers:
logging.root.removeHandler(h) # remove all handlers associated with the root logger object
).
I add handlers to the root logger so that I can log all 3rd party modules to a log file, and yolov5 doing this is deleting these handlers and making it not possible for me to load yolov5 and log its output to a file with the rest of my program's output (without resorting to some ugly runtime hacks).

Maybe there is something I am missing? Is it possible to make this behavior optional? Happy to submit a PR.

Environment

Newest Yolov5 master on Ubuntu 20 LTS.

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions