Skip to content

Commit 98fdcaf

Browse files
author
rain
committed
add logger
1 parent 9b2e2c4 commit 98fdcaf

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ class ProductionConfig(Config):
4646
def init_app(cls, app):
4747
Config.init_app(app)
4848

49+
import logging
50+
from logging.handlers import RotatingFileHandler
51+
file_handler = RotatingFileHandler('/devdmp/log/devdmp.log',
52+
mode='w', maxBytes=1024 * 1024 * 100,
53+
backupCount=20,
54+
encoding="utf-8")
55+
file_handler.setLevel(logging.WARNING)
56+
app.logger.addHandler(file_handler)
57+
58+
from logging import Formatter
59+
file_handler.setFormatter(Formatter(
60+
'%(asctime)s %(levelname)s: %(message)s '
61+
'[in %(pathname)s:%(lineno)d]'
62+
))
63+
4964
# email errors to the administrators
5065
import logging
5166
from logging.handlers import SMTPHandler

0 commit comments

Comments
 (0)