From 48f4a9da19b79b94b90e052a4fa84a51510dd91c Mon Sep 17 00:00:00 2001 From: xfc Date: Mon, 19 Jun 2023 13:36:27 +0800 Subject: [PATCH] logger_test --- TP_API/settings.py | 24 +++++++++++++++++------- requirements.txt | Bin 582 -> 700 bytes 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/TP_API/settings.py b/TP_API/settings.py index b4a19dd..3aba9b6 100644 --- a/TP_API/settings.py +++ b/TP_API/settings.py @@ -162,7 +162,7 @@ REST_FRAMEWORK = { } # 配置日志 -LOG_DIR = os.path.join(BASE_DIR, 'logs/') +LOG_DIR = os.path.join(BASE_DIR, 'logs') LOGGING = { 'version': 1, # 保留字 'disable_existing_loggers': False, # 是否禁用已经存在的日志实例 @@ -191,13 +191,23 @@ LOGGING = { 'formatter': 'simple', # 'filename': os.path.join(BASE_LOG_DIR, "tpservice.log") }, + # 'file': { + # 'level': 'INFO', + # 'class': 'concurrent_log_handler.ConcurrentRotatingFileHandler', # window多进程 需要 pip install concurrent-log-handler + # 'filename': os.path.join(BASE_DIR, "logs/debug.log"), # 日志文件 + # 'backupCount': 10, # 保留的最大文件数,超过则删除日期最早的 + # 'maxBytes': 1024, # 文件大小 + # 'formatter': 'standard', + # 'encoding': 'utf-8', + # }, 'file': { - 'level': 'DEBUG', - 'class': 'logging.handlers.TimedRotatingFileHandler', - 'filename': os.path.join(LOG_DIR, 'debug.log'), # 日志文件 - 'when': "D", - 'interval': 1, - 'formatter': 'standard' + 'level': 'INFO', + 'class': 'cloghandler.ConcurrentRotatingFileHandler', # linux多进程 需要 pip install ConcurrentLogHandler + 'filename': os.path.join(BASE_DIR, "logs/debug.log"), # 日志文件 + 'backupCount': 10, # 保留的最大文件数,超过则删除日期最早的 + 'maxBytes': 1024, # 文件大小 + 'formatter': 'standard', + 'encoding': 'utf-8', }, }, 'loggers': { # 日志实例 记录器 diff --git a/requirements.txt b/requirements.txt index 1697ec3007bfaffd51ce4ed9310657f2f5d06a72..f9945863bb065820f8166cc03eafcd03078bf328 100644 GIT binary patch delta 126 zcmX@cvWInp8&g>_Lq0Y`3|tJ(SoHgVb$j5{YsdfqSQi%N delta 7 OcmdnPdW>a*8xsHv)dGY7