Update configuration.py to use LOGGING environment variable

Update configuration.py to use a LOGGING environment variable to allow LOGGING configuration to be set via docker-compose.

LOGGING environment variable should be set to the full dictionary - example below:
`LOGGING: "{'version': 1, 'disable_existing_loggers': False, 'formatters': { 'timestamp': { 'format': '{asctime} {levelname} {message}', 'style': '{', }, }, 'handlers': { 'netbox-auth': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'timestamp', 'filename': '/var/log/netbox/netbox-auth.log', }, 'netbox': { 'level': 'DEBUG', 'class': 'logging.FileHandler', 'formatter': 'timestamp', 'filename': '/var/log/netbox/netbox.log', }, }, 'loggers': { 'netbox.auth': { 'handlers': ['netbox-auth'], 'level': 'DEBUG', }, 'django_auth_ldap': { 'handlers': ['netbox-auth'], 'level': 'DEBUG', }, 'netbox.views': { 'handlers': ['netbox'], 'level': 'DEBUG', }, 'netbox.api.views': { 'handlers': ['netbox'], 'level': 'DEBUG', }, },}"`
This commit is contained in:
jbromwic 2020-05-19 16:57:19 +01:00 committed by GitHub
parent 45f7823a17
commit d4a7a4ab5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,7 @@
import os
import re
import socket
import ast
# For reference see http://netbox.readthedocs.io/en/latest/configuration/mandatory-settings/
# Based on https://github.com/netbox-community/netbox/blob/develop/netbox/netbox/configuration.example.py
@ -144,7 +145,10 @@ EXEMPT_VIEW_PERMISSIONS = list(filter(None, os.environ.get('EXEMPT_VIEW_PERMISSI
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
# https://docs.djangoproject.com/en/1.11/topics/logging/
LOGGING = {}
if "LOGGING" in os.environ:
LOGGING = ast.literal_eval(os.environ.get('LOGGING'))
else:
LOGGING = {}
# Setting this to True will permit only authenticated users to access any part of NetBox. By default, anonymous users
# are permitted to access most data in NetBox (excluding secrets) but not make any changes.