From 4cf7b93ee20b29feb450fcc89202c26dd5b56827 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 13 Apr 2019 12:02:48 +0200 Subject: [PATCH 1/2] Create logs directory --- logs/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 logs/.keep diff --git a/logs/.keep b/logs/.keep new file mode 100644 index 00000000..e69de29b From f50af4f2aaabe7efef12b332b55e15c9c5b5ff63 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 13 Apr 2019 12:04:18 +0200 Subject: [PATCH 2/2] Improve log formatting --- dynamicweb/settings/base.py | 14 +++++++++++--- logs/{.keep => .gitkeep} | 0 2 files changed, 11 insertions(+), 3 deletions(-) rename logs/{.keep => .gitkeep} (100%) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 49570143..324de04d 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -685,18 +685,26 @@ if ENABLE_LOGGING: custom_handler_item = { 'custom_file': { 'level': LOG_LEVEL, - 'class': 'logging.FileHandler', + 'class': 'logging.handlers.RotatingFileHandler', 'filename': - "{PROJECT_DIR}/{LEVEL}.log".format( + "{PROJECT_DIR}/logs/{LEVEL}.log".format( LEVEL=LOG_LEVEL.lower(), PROJECT_DIR=PROJECT_DIR - ) + ), + 'maxBytes': 1024 * 1024 * 5, + 'backupCount': 10, + 'formatter': 'standard', } } handlers_dict.update(custom_handler_item) LOGGING = { 'version': 1, 'disable_existing_loggers': False, + 'formatters': { + 'standard': { + 'format': '%(asctime)s %(levelname)s %(name)s: %(message)s' + } + }, 'handlers': handlers_dict, 'loggers': loggers_dict } diff --git a/logs/.keep b/logs/.gitkeep similarity index 100% rename from logs/.keep rename to logs/.gitkeep