如何在Django Debug工具栏中使用Logging? [英] How do I use Logging in the Django Debug Toolbar?

查看:89
本文介绍了如何在Django Debug工具栏中使用Logging?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在视图功能的不同点在我的django应用程序中输出调试消息。 django-debug-toolbar 的文档表示它使用python日志记录中的构建,但是找不到任何更多的信息。我真的不想登录到文件,但是不想登录到工具栏上的信息窗格。这是如何工作的?

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?

推荐答案

你只需使用记录模块方法,DjDT将拦截并显示在记录面板中。

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')

这篇关于如何在Django Debug工具栏中使用Logging?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆