How do I use Logging in the Django Debug Toolbar?

reconbot picture reconbot · Apr 10, 2010 · Viewed 9.8k times · Source

I would like to output debug messages in my django app at different points in a view function. The docs for the django-debug-toolbar say it uses the build in python logging but I can't find any more information then that. I don't really want to log to a file but to the info pane on the toolbar. How does this work?

Answer

user136565 picture user136565 · Apr 10, 2010

You just use the logging module methods and DjDT will intercept and display them in the Logging Panel.

import logging

logging.debug('Debug Message')

if some_error:
   logging.error('Error Message')