1👍
You are getting the error because ‘project.logging.SpecialFilter’ doesn’t exist and you have to create this class/method in your django project.
Create module ‘mylogging.py’ in / directory, where settings.py and wsgi.py and url.py is present.
A sample SpecialFilter implementation:-
import logging
from random import choice
class SpecialFilter(logging.Filter):
# """
# This is a filter which injects contextual information into the log.
#
# Rather than use actual contextual information, we just use random
# data in this demo.
# """
USERS = ['jim', 'fred', 'sheila']
IPS = ['123.231.231.123', '127.0.0.1', '192.168.0.1']
def filter(self, record):
record.ip = choice(SpecialFilter.IPS)
record.user = choice(SpecialFilter.USERS)
return True
Also fix your setting.py to properly point to the new SpecialFilter module location.
'filters': {
'special': {
'()': '<your_project_name>.mylogging.SpecialFilter',
# '()': 'django.utils.log.RequireDebugTrue',
# 'foo': 'bar',
},
Source:stackexchange.com