Skip to content

Root logger default logging level is changed after importing neural_compressor #122

@valeriosofi

Description

@valeriosofi

Hello, I've noticed that simply importing neural_compressor causes issues with the root logger. It changes the logging level from the default WARNING to INFO, and this is not a good behaviour because it can change the logging level of the loggers of other imported libraries, letting them print all the INFO stuff that sometimes can be a bit too much. Generally the good practice would be to use a named logger (for example logger=logging.getLogger("neural_compressor")) and not the root one, so that when you set its level you don't change te default level of all the loggers. You can reproduce the issue with this small code snippet:

import logging
print(logging.getLogger())
import neural_compressor
print(logging.getLogger())

The output will be:

<RootLogger root (WARNING)>
2022-10-29 07:43:46 [INFO] NumExpr defaulting to 2 threads.
2022-10-29 07:43:49 [INFO] Generating grammar tables from /usr/lib/python3.7/lib2to3/Grammar.txt
2022-10-29 07:43:49 [INFO] Generating grammar tables from /usr/lib/python3.7/lib2to3/PatternGrammar.txt
<RootLogger root (INFO)>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions