Skip to content

Commit 8176ef8

Browse files
committed
Add expample logging configuration
1 parent eb5cc88 commit 8176ef8

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ configuration/*
99
configuration/ldap/*
1010
!configuration/ldap/extra.py
1111
!configuration/ldap/ldap_config.py
12+
!configuration/logging.py
1213
!configuration/plugins.py
1314
prometheus.yml
1415
super-linter.log

configuration/logging.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
from os import environ
2+
3+
# Set LOGLEVEL in netbox.env or docker-compose.overide.yml to override a logging level of INFO.
4+
LOGLEVEL = environ.get('LOGLEVEL', 'INFO')
5+
6+
LOGGING = {
7+
8+
'version': 1,
9+
'disable_existing_loggers': False,
10+
'formatters': {
11+
'verbose': {
12+
'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
13+
'style': '{',
14+
},
15+
'simple': {
16+
'format': '{levelname} {message}',
17+
'style': '{',
18+
},
19+
},
20+
'filters': {
21+
'require_debug_false': {
22+
'()': 'django.utils.log.RequireDebugFalse',
23+
},
24+
},
25+
'handlers': {
26+
'console': {
27+
'level': LOGLEVEL,
28+
'filters': ['require_debug_false'],
29+
'class': 'logging.StreamHandler',
30+
'formatter': 'simple'
31+
},
32+
'mail_admins': {
33+
'level': 'ERROR',
34+
'class': 'django.utils.log.AdminEmailHandler',
35+
'filters': ['require_debug_false']
36+
}
37+
},
38+
'loggers': {
39+
'django': {
40+
'handlers': ['console'],
41+
'propagate': True,
42+
},
43+
'django.request': {
44+
'handlers': ['mail_admins'],
45+
'level': 'ERROR',
46+
'propagate': False,
47+
},
48+
'django_auth_ldap': {
49+
'handlers': ['console',],
50+
'level': LOGLEVEL,
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)