1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| # LOGGING setting LOG_DIR = BASE_DIR + "/logs" if not os.path.exists(LOG_DIR): os.mkdir(LOG_DIR)
LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'standard': { 'format': '%(asctime)s FuncName:%(funcName)s LINE:%(lineno)d [%(levelname)s]- %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(funcName)s %(message)s' }, }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'standard' }, 'default': { 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'info.log'), 'maxBytes': 1024 * 1024 * 50, # 50 MB 'backupCount': 2, 'formatter': 'standard', }, 'default_debug': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'debug.log'), 'maxBytes': 1024 * 1024 * 50, # 50 MB 'backupCount': 2, 'formatter': 'standard', }, 'request_handler': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'common.log'), 'maxBytes': 1024 * 1024 * 50, # 50 MB 'backupCount': 2, 'formatter': 'standard', }, 'restful_api': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'filename': os.path.join(LOG_DIR, 'api.log'), 'maxBytes': 1024 * 1024 * 50, # 50 MB 'backupCount': 2, 'formatter': 'verbose', }, }, 'loggers': { 'django': { 'handlers': ['console', 'default_debug'], 'level': 'INFO', 'propagate': False }, 'django.request': { 'handlers': ['request_handler'], 'level': 'INFO', 'propagate': False }, 'common': { 'handlers': ['default', 'console'], 'level': 'INFO', 'propagate': True }, 'api': { 'handlers': ['restful_api'], 'level': 'INFO', 'propagate': True }, } }
|