django日志配置
2016-01-06 14:26
537 查看
#配置应用的日志handlers APP_LOG_HANDLERS = ['default', 'console', 'default_debug'] # settings.py LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'standard': { 'format': '%(asctime)s FuncName:%(funcName)s LINE:%(lineno)d [%(levelname)s]- %(message)s', 'datefmt' : "%Y-%m-%d %H:%M:%S" }, 'simple': { 'format': '%(levelname)s %(message)s', 'datefmt' : "%Y-%m-%d %H:%M:%S" }, 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s', 'datefmt' : "%Y-%m-%d %H:%M:%S" }, 'verbose1': { 'format' : "[%(asctime)s] [%(levelname)s] [%(name)s.%(funcName)s:%(lineno)s] %(message)s", 'datefmt' : "%Y-%m-%d %H:%M:%S" }, }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'mail_admins': { 'level': 'DEBUG', # 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler', 'include_html': False, # 'email_backend': 'django.core.mail.backends.filebased.EmailBackend', }, 'default': { 'level':'INFO', 'class':'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'autoop_info.log'), 'maxBytes': 1024 * 1024 * 500, # 5 MB 'backupCount': 5, 'formatter':'verbose1', }, 'default_debug': { 'level':'DEBUG', 'class':'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'autoop_debug.log'), 'maxBytes': 1024 * 1024 * 500, # 5 MB 'backupCount': 5, 'formatter':'verbose1', }, 'console':{ 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose1' }, 'request_handler': { 'level':'DEBUG', 'class':'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'autoop_script.log'), 'maxBytes': 1024 * 1024 * 500, # 5 MB 'backupCount': 5, 'formatter':'verbose1', }, 'scprits_handler': { 'level':'DEBUG', 'class':'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'autoop_script.log'), 'maxBytes': 1024 * 1024 * 500, # 5 MB 'backupCount': 5, 'formatter':'verbose1', }, }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'DEBUG', 'propagate': True, }, 'django': { 'handlers': ['default', 'console'], 'level': 'DEBUG', 'propagate': False }, 'django.request': { 'handlers': ['request_handler', 'console'], 'level': 'DEBUG', 'propagate': False }, 'scripts': { 'handlers': ['scprits_handler', 'console'], 'level': 'ERROR', 'propagate': False }, 'app1':{ 'handlers': APP_LOG_HANDLERS, 'level': 'DEBUG', 'propagate': True }, 'app2':{ 'handlers': APP_LOG_HANDLERS, 'level': 'DEBUG', 'propagate': True }, 'utils':{ 'handlers': APP_LOG_HANDLERS, 'level': 'DEBUG', 'propagate': True }, 'app.custom':{ 'handlers': APP_LOG_HANDLERS, 'level': 'DEBUG', 'propagate': True }, } } import logging logger = logging.getLogger(__name__) or logger = logging.getLogger("app.custom")
相关文章推荐
- MySQL Server 日志
- Awstats处理多apache日志
- 典型入侵日志分析
- MSSQL 2005 LOG备份webshell的方法
- MS SQL Server数据库清理错误日志的方法
- 对MySQL日志操作的一些基本命令总结
- 简介操作MySQL日志的一些方法
- MySQL的日志基础知识及基本操作学习教程
- MSSQL 2005/2008 日志压缩清理方法小结
- SQL Server误区30日谈 第19天 Truncate表的操作不会被记录到日志
- C#3.0使用EventLog类写Windows事件日志的方法
- 使用MySQL Slow Log来解决MySQL CPU占用高的问题
- MySQL中查询日志与慢查询日志的基本学习教程
- mysql binlog二进制日志详解
- C#实现线程安全的简易日志记录方法
- C#实现将程序运行信息写入日志的方法
- ORACLE DATAGUARD中手工处理日志v$archive_GAP的方法
- 某个aspx页面突然死了连日志也没有的解决方法
- django中使用jquery ajax post数据出现403错误的解决办法(两种方法)
- django使用ajax post数据出现403错误如何解决