Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update configuration.py to use LOGGING environment variable #299

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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', }, },}"`
  • Loading branch information
jbromwic authored May 19, 2020
commit d4a7a4ab5a4c7fb57df1d011928211da9c19d33b
6 changes: 5 additions & 1 deletion configuration/configuration.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -144,7 +145,10 @@ def read_secret(secret_name):

# 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.
Expand Down