mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-06-07 01:51:21 -04:00
try to improve django console log 404 and 200 error filtering
This commit is contained in:
parent
01094ecb03
commit
f915ef6c5e
1 changed files with 14 additions and 5 deletions
|
@ -356,8 +356,8 @@ IGNORABLE_404_URLS = [
|
||||||
re.compile(r'.*\.(css|js)\.map$'),
|
re.compile(r'.*\.(css|js)\.map$'),
|
||||||
]
|
]
|
||||||
IGNORABLE_200_URLS = [
|
IGNORABLE_200_URLS = [
|
||||||
re.compile(r'^"GET /static/.* HTTP/.*" (200|30.) .+', re.I | re.M),
|
re.compile(r'.*"GET /static/.* HTTP/.*" 2|3.+', re.I | re.M),
|
||||||
re.compile(r'^"GET /admin/jsi18n/ HTTP/.*" (200|30.) .+', re.I | re.M),
|
re.compile(r'.*"GET /admin/jsi18n/ HTTP/1.1" 200 .+', re.I | re.M),
|
||||||
]
|
]
|
||||||
|
|
||||||
class NoisyRequestsFilter(logging.Filter):
|
class NoisyRequestsFilter(logging.Filter):
|
||||||
|
@ -366,11 +366,11 @@ class NoisyRequestsFilter(logging.Filter):
|
||||||
|
|
||||||
# ignore harmless 404s for the patterns in IGNORABLE_404_URLS
|
# ignore harmless 404s for the patterns in IGNORABLE_404_URLS
|
||||||
for ignorable_url_pattern in IGNORABLE_404_URLS:
|
for ignorable_url_pattern in IGNORABLE_404_URLS:
|
||||||
ignorable_log_pattern = re.compile(f'^"GET /.*/?{ignorable_url_pattern.pattern[:-1]} HTTP/.*" (200|30.|404) .+$', re.I | re.M)
|
ignorable_log_pattern = re.compile(f'"GET /.*/?{ignorable_url_pattern.pattern[:-1]} HTTP/.*" (200|30.|404) .+$', re.I | re.M)
|
||||||
if ignorable_log_pattern.match(logline):
|
if ignorable_log_pattern.match(logline):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
ignorable_log_pattern = re.compile(f'^Not Found: /.*/?{ignorable_url_pattern.pattern}', re.I | re.M)
|
ignorable_log_pattern = re.compile(f'Not Found: /.*/?{ignorable_url_pattern.pattern}', re.I | re.M)
|
||||||
if ignorable_log_pattern.match(logline):
|
if ignorable_log_pattern.match(logline):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -400,6 +400,7 @@ LOGGING = {
|
||||||
"filters": [],
|
"filters": [],
|
||||||
'formatter': 'simple',
|
'formatter': 'simple',
|
||||||
"class": "logging.StreamHandler",
|
"class": "logging.StreamHandler",
|
||||||
|
'filters': ['noisyrequestsfilter'],
|
||||||
},
|
},
|
||||||
'logfile': {
|
'logfile': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
|
@ -408,6 +409,7 @@ LOGGING = {
|
||||||
'maxBytes': 1024 * 1024 * 25, # 25 MB
|
'maxBytes': 1024 * 1024 * 25, # 25 MB
|
||||||
'backupCount': 10,
|
'backupCount': 10,
|
||||||
'formatter': 'verbose',
|
'formatter': 'verbose',
|
||||||
|
'filters': ['noisyrequestsfilter'],
|
||||||
},
|
},
|
||||||
# "mail_admins": {
|
# "mail_admins": {
|
||||||
# "level": "ERROR",
|
# "level": "ERROR",
|
||||||
|
@ -469,7 +471,14 @@ LOGGING = {
|
||||||
'filters': ['noisyrequestsfilter'],
|
'filters': ['noisyrequestsfilter'],
|
||||||
'propagate': False,
|
'propagate': False,
|
||||||
"formatter": "django.server",
|
"formatter": "django.server",
|
||||||
}
|
},
|
||||||
|
'django.request': {
|
||||||
|
'handlers': ['console', 'logfile'],
|
||||||
|
'level': 'INFO',
|
||||||
|
'filters': ['noisyrequestsfilter'],
|
||||||
|
'propagate': False,
|
||||||
|
"formatter": "django.server",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue