Django日志:任何教程来登录文件 [英] Django logs: any tutorial to log to a file

查看:127
本文介绍了Django日志:任何教程来登录文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在和django项目合作,我还没有开始。开发的工程项目离开了。在知识转移过程中,告诉我所有的事件都记录到数据库中。我没有找到数据库接口有用的搜索日志,有时他们甚至不记录(我可能是错的)。我想知道,如果有一个简单的教程,解释如何使用最少的配置更改在Django中启用日志记录。



谢谢

Bala

解决方案

如果您正在谈论Django管理日志(显示在管理界面主页右侧的日志),您可以为日志本身启用管理模型。



打开 admin.py 您的django应用程序并添加:

  from django.contrib.admin.models import LogEntry 

class LogEntryAdmin(admin.ModelAdmin):
list_display =('content_type','user','action_time')

admin.site.register(LogEntry,LogEntryAdmin)

它将为您提供一个用于查看日志的准系统界面。



请记住,日志只记录通过管理界面本身发生的任何事情。


I am working with a django project, I haven't started. The developed working on the project left. During the knowledge transfer, it was told to me that all the events are logged to the database. I don't find the database interface useful to search for logs and sometimes they don't even log(I might be wrong). I want to know, if there is an easy tutorial that explains how to enable logging in Django with minimal configuration changes.

Thank you
Bala

解决方案

If you are talking about the Django admin log (the one that shows on the right side of the main page of the admin interface), you could just enable an admin model for the log itself.

Open the admin.py for one of your django apps and add this:

from django.contrib.admin.models import LogEntry

class LogEntryAdmin(admin.ModelAdmin):
    list_display = ('content_type', 'user', 'action_time')

admin.site.register(LogEntry, LogEntryAdmin)

It will give you a barebones interface for looking at the log.

Remember that log is only logging whatever happens through the admin interface itself.

这篇关于Django日志:任何教程来登录文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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