标签:erb gate format djang log handlers dex ble att
LOG_LEVEL=‘DEBUG‘ LOGGING = { ‘version‘: 1, ‘disable_existing_loggers‘: False, ‘formatters‘: { ‘verbose‘: { ‘format‘: ‘%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s‘, }, ‘normal‘: { ‘format‘: ‘%(asctime)s [%(levelname)s] %(module)s/%(filename)s[line:%(lineno)d] %(message)s‘, ‘datefmt‘:‘%Y%m%d %H:%M:%S‘, }, ‘test‘:{ ‘format‘:‘%(asctime)s %(module)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s‘ } }, ‘handlers‘: { ‘null‘: { ‘level‘: ‘DEBUG‘, ‘class‘: ‘logging.NullHandler‘, }, ‘console‘: { ‘level‘: ‘DEBUG‘, ‘class‘: ‘logging.StreamHandler‘, ‘formatter‘: ‘normal‘ }, ‘logfile‘: { ‘level‘: ‘DEBUG‘, ‘class‘: ‘logging.FileHandler‘, ‘filename‘: os.path.join(BASE_DIR, ‘logs‘,‘server.log‘), ‘formatter‘: ‘normal‘ }, ‘ansible_logfile‘: { ‘level‘: ‘DEBUG‘, ‘class‘: ‘logging.FileHandler‘, ‘formatter‘: ‘normal‘, ‘filename‘: os.path.join(BASE_DIR, ‘logs‘, ‘ansible.log‘), }, ‘test_logfile‘: { ‘level‘: ‘DEBUG‘, ‘class‘: ‘logging.FileHandler‘, ‘filename‘: os.path.join(BASE_DIR, ‘logs‘,‘test.log‘), ‘formatter‘: ‘test‘ } }, ‘loggers‘: { ‘django‘: { ‘handlers‘: [‘console‘, ‘logfile‘], ‘level‘: ‘INFO‘, ‘propagate‘: False, }, ‘appcommon‘: { ‘handlers‘: [‘console‘, ‘logfile‘], ‘level‘: LOG_LEVEL, ‘propagate‘: False, }, ‘app01.views‘: { ‘handlers‘: [‘console‘, ‘test_logfile‘], ‘level‘: LOG_LEVEL, ‘propagate‘: False }, ‘app01‘: { ‘handlers‘: [‘console‘, ‘logfile‘], ‘level‘: LOG_LEVEL, ‘propagate‘: False }, ‘ansible‘: { ‘handlers‘: [‘console‘, ‘ansible_logfile‘], ‘level‘: LOG_LEVEL, ‘propagate‘: False }, } }
使用
# Create your views here. import logging logger=logging.getLogger(__name__) # 优先使用完全匹配,若找不到,app01也行 def index(request): print(__name__) logger.error(‘eeee‘)
标签:erb gate format djang log handlers dex ble att
原文地址:https://www.cnblogs.com/infaaf/p/9503070.html