首页 > 学院 > 开发设计 > 正文

django日志配置

2019-11-10 18:43:24
字体:
来源:转载
供稿:网友
LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'main_format':{ 'format': '[%(levelname)s] [%(asctime)s] [%(pathname)s] [%(module)s] [%(lineno)d] [%(message)s] ', 'datefmt': '%Y-%m-%d %H:%M:%S' }, }, 'handlers': { 'main':{ 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(PROJECT_DIR, '../log/Main.log'),#you need define your VAR_ROOT variable that points to your project path,and mkdir a logs directory in your project root path. 'backupCount': 5, 'maxBytes': 16777216, # 16megabytes(16M) 'formatter': 'main_format' }, 'django_request_logfile':{ 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(PROJECT_DIR, '../log/request.log'),#you need define your VAR_ROOT variable that points to your project path,and mkdir a logs directory in your project root path. 'backupCount': 5, 'maxBytes': 16777216, # 16megabytes(16M) 'formatter': 'main_format' } }, 'loggers': { 'Main': { 'handlers': ['main'], 'level': 'INFO', } , 'django.request':{ 'handlers': ['django_request_logfile'], 'level': 'ERROR', 'propagate': False } }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表