The release notes say:
Django 1.3 adds framework-level support for Python’s logging module.
That's nice. I'd like to take advantage of that. Unfortunately the documentation doesn't hand it all to me on a silver platter in the form of complete working example code which demonstrates how simple and valuable this is.
How do I set up this funky new feature such that I can pepper my code with
logging.debug('really awesome stuff dude: %s' % somevar)
and see the file "/tmp/application.log" fill up with
18:31:59 Apr 21 2011 awesome stuff dude: foobar
18:32:00 Apr 21 2011 awesome stuff dude: foobar
18:32:01 Apr 21 2011 awesome stuff dude: foobar
What's the difference between the default Python logging and this 'framework-level support'?
Based partially on the logging config suggested by rh0dium and some more research I did myself, I started assembling an example Django project with nice logging defaults – fail-nicely-django.
Sample logfile output:
The detailed usage is explained in the README, but essentially, you copy the logger module to your Django project and add
from .logger import LOGGING
at the bottom of your settings.py.I truly love this so much here is your working example! Seriously this is awesome!
Start by putting this in your
settings.py
Now what does all of this mean?
Now how do I enable MYAPP to use it...
Per the documentation put this at the top of your files (views.py)..
Then to get something out do this.
Log levels are explained here and for pure python here.