Elegant setup of Python logging in Django
- by Parand
I have yet to find a way of setting up Python logging with Django that I'm happy with. My requirements are fairly simple:
Different log handlers for different events - that is, I want to be able to log to different files
Easy access to loggers in my modules. The module should be able to find its logger with little effort.
Should be easily applicable to command-line modules. Parts of the system are stand-alone command line or daemon processes. Logging should be easily usable with these modules.
My current setup is to use a logging.conf file and setup logging in each module I log from. It doesn't feel right.
Do you have a logging setup that you like? Please detail it: how do you setup the configuration (do you use logging.conf or set it up in code), where/when do you initiate the loggers, and how do you get access to them in your modules, etc.