Django logs: any tutorial to log to a file

谁说胖子不能爱 提交于 2019-12-12 09:58:29

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/2479858/django-logs-any-tutorial-to-log-to-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!