diff --git a/example_project/.gitignore b/example_project/.gitignore index 853dd25..1392c1d 100644 --- a/example_project/.gitignore +++ b/example_project/.gitignore @@ -2,3 +2,4 @@ static venv settings_local.py +logs/*.log diff --git a/example_project/logs/.keep b/example_project/logs/.keep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/example_project/logs/.keep diff --git a/example_project/settings.py b/example_project/settings.py index de5fe66..56f2670 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -244,25 +244,45 @@ # EMAIL_CONFIRMATION_TEMPLATE = 'postorius/address_confirmation_message.txt' # EMAIL_CONFIRMATION_SUBJECT = 'Confirmation needed' -# You can enable logging by uncommenting the following lines + LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { - 'class': 'logging.StreamHandler' + 'class': 'logging.StreamHandler', + 'formatter': 'simple', + }, + 'file':{ + 'level': 'INFO', + #'class': 'logging.handlers.RotatingFileHandler', + 'class': 'logging.handlers.WatchedFileHandler', + 'filename': os.path.join(BASE_DIR, 'logs', 'postorius.log'), + 'formatter': 'verbose', }, }, 'loggers': { 'django': { - 'handlers': ['console'], + 'handlers': ['console', 'file'], 'level': 'INFO', }, + 'django.request': { + 'handlers': ['console', 'file'], + 'level': 'ERROR', + }, 'postorius': { - 'handlers': ['console'], + 'handlers': ['console', 'file'], 'level': 'INFO', }, }, + 'formatters': { + 'simple': { + 'format': '%(levelname)s: %(message)s' + }, + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s' + }, + }, } diff --git a/example_project/test_settings.py b/example_project/test_settings.py index 8f08d9a..d615896 100644 --- a/example_project/test_settings.py +++ b/example_project/test_settings.py @@ -26,3 +26,34 @@ MAILMAN_REST_API_URL = 'http://localhost:9001' MAILMAN_REST_API_USER = 'restadmin' MAILMAN_REST_API_PASS = 'restpass' + + +LOGGING = { + 'version': 1, + 'disable_existing_loggers': False, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'verbose', + }, + }, + 'loggers': { + 'django': { + 'handlers': ['console'], + 'level': 'INFO', + }, + 'django.request': { + 'handlers': ['console'], + 'level': 'ERROR', + }, + 'postorius': { + 'handlers': ['console'], + 'level': 'INFO', + }, + }, + 'formatters': { + 'verbose': { + 'format': '%(levelname)s %(asctime)s %(process)d %(name)s %(message)s' + }, + }, +}