From 2f7ddd590aad5d10b0b74452a502d56fb206bf1c Mon Sep 17 00:00:00 2001 From: wuxj <1846781197@qq.com> Date: Tue, 16 Mar 2021 13:53:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0log.ini?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- conf/log.ini | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 conf/log.ini diff --git a/.gitignore b/.gitignore index c43ae86..44b67bd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ .vscode *.pyc __pycache__/ -conf/* +conf/conf-*.ini my.setting server.setting static/img/banners/* diff --git a/conf/log.ini b/conf/log.ini new file mode 100644 index 0000000..12a9c71 --- /dev/null +++ b/conf/log.ini @@ -0,0 +1,65 @@ +[loggers] +keys=root, gunicorn.error, gunicorn.access,uvicorn.error,uvicorn.access, + +[handlers] +keys=error_file, access_file + +[formatters] +keys=generic, access, error + +[logger_root] +level=DEBUG +handlers=access_file + +[logger_] +level=INFO +handlers=access_file +qualname= +propagate=0 + +[logger_uvicorn.error] +level=ERROR +handlers=error_file +qualname=uvicorn.error +propagate=0 + +[logger_uvicorn.access] +level=INFO +handlers=access_file +qualname=uvicorn.access +propagate=0 + +[logger_gunicorn.error] +level=ERROR +handlers=error_file +qualname=gunicorn.error +propagate=1 + +[logger_gunicorn.access] +level=INFO +handlers=access_file +qualname=gunicorn.access +propagate=1 + +[handler_error_file] +class=logging.handlers.RotatingFileHandler +formatter=error +kwargs={"filename": "./log/error.log", "maxBytes": 1024 * 1024 * 10, "backupCount": 10, "delay": True} + +[handler_access_file] +class=logging.handlers.RotatingFileHandler +formatter=access +kwargs={"filename": "./log/access.log", "maxBytes": 1024 * 1024 * 10, "backupCount": 10, "delay": True} + +[formatter_generic] +format=%(asctime)s %(pathname)s(%(lineno)d): %(levelname)s %(message)s +datefmt=%Y-%m-%d %H:%M:%S +class=logging.Formatter + +[formatter_access] +format=[%(asctime)s] %(levelname)s in %(module)s: %(message)s +class=logging.Formatter + +[formatter_error] +format=[%(asctime)s] %(levelname)s in %(module)s: %(message)s +class=logging.Formatter \ No newline at end of file