2011-08-08 4 views
9

나는 다음과 같은 한 로깅 설정 :파이썬/장고 루트 로거 수준

DEBUG south 2011-08-08 11:22:23,847 generic 19539 140735078710464 south execute "..." 

I :

LOGGING = { 
    'version': 1, 
    'disable_existing_loggers': True, 
    'formatters': { 
     'verbose': { 
      'format': '%(name)s %(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' 
     }, 
     'simple': { 
      'format': '%(levelname)s %(message)s' 
     }, 
    }, 
    'handlers': { 
     'null': { 
      'level': 'DEBUG', 
      'class':'django.utils.log.NullHandler', 
     }, 
     'sentry': { 
      'level': 'DEBUG', 
      'class': 'sentry.client.handlers.SentryHandler', 
      'formatter': 'verbose' 
     }, 
     'console': { 
      'level': 'DEBUG', 
      'class': 'logging.StreamHandler', 
      'formatter': 'verbose' 
     } 
    }, 
    'loggers': { 
     'django.db.backends': { 
      'handlers': ['console'], 
      'level': 'INFO', 
      'propagate': False, 
     }, 
     '': { 
      'level': 'ERROR', 
      'handlers': ['console'], 
     }, 
    }, 
} 

manage.py migrate를 실행 난 아직도 콘솔에서 예를 디버그 물건을 많이 가지고 루트 로거 수준을 ERROR로 설정하면 콘솔에서 오류 메시지 만 예상됩니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

import sys 
import logging 
from django.conf import settings 

# Create a dummy handler to use for now. 
class NullHandler(logging.Handler): 
    def emit(self, record): 
     pass 

_logger = logging.getLogger("south") 
_logger.addHandler(NullHandler()) 
_logger.setLevel(logging.DEBUG) 

예상대로 _logger.setLevel(logging.DEBUG) 로깅이 작동 제거한 후 : 문제가 south.logger 모듈처럼

UPDATE

보인다.

누군가 저에게 이상한 행동을 설명 할 수 있습니까?

+0

+1 그래서 다른 라이브러리 개발자는 할 수없는 것을 배울 수 있습니다 * – SingleNegationElimination

답변

12

한국 개발자는 최상위 레벨 로거 레벨을 DEBUG로 설정해서는 안됩니다. 실제로 설정하지 않으면 루트 로거의 레벨을 상속받습니다. 루트 로거 레벨은 일반적으로 응용 프로그램 개발자가 정의합니다 (이 경우에는 여러분이라고 생각합니다).

관련 South 포럼의 버그로 신고하는 것이 좋습니다.