Handler for Global Logger in Python

Posted by in Software, Tutorial

While writing a command line tool, I’ve stumbled upon a strange situation: Some logs were written to a file while some others were printed to console. Quite annoying, particularly since every module I use has its own logger via logging.getLogger(__name__).

After some investigation I found out you can access the global logger via logging.getLogger() (note the lack of parameters). So, my new setup is:



A little experiment: If you find this post and ad below useful, please check the ad out :-)