[Answered ]-Django Logger creates file but doesn't write in it

2👍

You have named your logger ‘INFO’, but you have asked for logger __name__. So the logger you use is not the one you want.

Your best bet is to use the root logger, like this:

LOGGING = {
    ...
    'root': {
        'handlers': ['file_INFO', ],
        'level': 'INFO',
    },
}

All loggers will propagate to the root logger (unless told otherwise), and this setup is enough for more than 90% of applications. If you use the root logger, you also don’t need to run getLogger(__name__), you can simply log with logging.info("some stuff").

Leave a comment