Django日志:任何教程来登录文件 [英] Django logs: any tutorial to log to a file
问题描述
谢谢
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屋!