开发者

Django logs: any tutorial to log to a file

开发者 https://www.devze.com 2022-12-23 06:30 出处:网络
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 do

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 w开发者_如何学编程rong). 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消