How to Enable Logging in Django 1.2
On Monday Django 1.2 was released. At Loggly, we highly anticipated this release. We have been running version 1.2 since the early Alpha releases. During the Alpha times, Simon Willison released a patch and proposal/ticket of how to enable logging in Django applications. It looked like the patch would get included in the main Django branch. Can you imagine how disappointed we were when the we realized that the patch didn’t make it into the final release?
Well, what we ended up doing was to patch Django with Simon’s patch. Took me a little while to update the patch to work with the final 1.2 release. If you want to use the patch, download it here. What you need to do then is patch your Django install with this. So, download the Django 1.2 tar ball and do the following:
This will include the patch into your Django distro and install it. As a next step, you configure your application for logging by adding a snippet similar to the following in your settings.py file:
From there you use the following code snippet to log out of your application:
More information about how to use the logging libraries you find in the Python documentation. It also seems like Django 1.3 will have logging built in. From what I can tell, it looks similar to Simon’s approach, but it’s not quite the same. I’ll keep you posted here!
In my next blog post I will show you how we implemented a logging library for Loggly so that we can very easily log from anywhere within our application.
L Jay Adams 31 Mar, 2011 03:16pm
I am curious to know if Django 1.2.3 included the patch.
If not, is there a separate patch for Django 1.2.3?