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 1697ec3..f994586 100644 Binary files a/requirements.txt and b/requirements.txt differ