Django unnamed default logger is overridden by imported package

In my django app, I have defined the logging configuration:

default_config = {
            'handlers': handlers_to_use,
            'level': 'WARN',

LOGGING: Dict[str, Any] = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': handler_configs,
    'root': default_config,
    'loggers': {
        '': default_config

So you can see Im using the unnamed logger '' and the root logger, which should set the default logging level to WARN. However, there are some packages (factory_boy and PIL) that are giving me DEBUG logs, which doesnt make sense because WARN should only give me ERROR and WARN logs, based on the heirarchy.

How are they overriding the default? If I add factory and PIL to the list of loggers, things work correctly, but Im wondering why the unnamed nor the root logger doesnt catch the debug logs

Any help would be greatly appreciated

You're still getting the loggers that are defined elsewhere, because of this line:

'disable_existing_loggers': False

The other packages like factory_boy and PIL are not overriding the default. You are just not overriding them.

If you disable the existing loggers, it's then on you to define everything yourself. You'll only get whatever's configured in your config.

Back to Top