我已经使用以下日志配置在 Django 1.4 上配置了 Raven 2.0.2:
'handlers': {
...
'sentry': {
'level':'INFO',
'class': 'raven.contrib.django.handlers.SentryHandler',
},
},
'loggers': {
'' : {
'level': 'INFO',
'handlers': ['sentry'],
},
'django' : {
'handlers': ['console-error', 'sentry'],
'propagate': False,
'level': 'DEBUG'
},
'django.request': {
'handlers': [],
'level': 'ERROR',
'propagate': True,
},
}
记录“django”记录器效果很好。对于根级别记录器,如果我尝试记录错误级别的消息,它会通过。但是,当我尝试记录 INFO 级别消息时,我收到以下错误:
Top level Sentry exception caught - failed creating log record
Configuring Raven for host: http://1e437dc0d8e347f2b655246d25aa3544:59b1969faf0b4f2e85a823fba93d058a@dev.project.com:9000:/3
Traceback (most recent call last):
File "/home/dev/env/project/lib/python2.6/site-packages/raven/handlers/logging.py", line 59, in emit
return self._emit(record)
File "/home/dev/env/project/lib/python2.6/site-packages/raven/contrib/django/handlers.py", line 32, in _emit
return super(SentryHandler, self)._emit(record, request=request)
File "/home/dev/env/project/lib/python2.6/site-packages/raven/handlers/logging.py", line 126, in _emit
return self.client.capture('Message', message=record.msg, params=record.args,
File "/home/dev/env/project/lib/python2.6/site-packages/raven/contrib/django/models.py", line 49, in <lambda>
__getattr__ = lambda x, o: getattr(get_client(), o)
File "/home/dev/env/project/lib/python2.6/site-packages/raven/contrib/django/models.py", line 133, in get_client
instance = getattr(__import__(module, {}, {}, class_name), class_name)(**options)
File "/home/dev/env/project/lib/python2.6/site-packages/raven/base.py", line 152, in __init__
self.logger.info(msg)
File "/usr/lib/python2.6/logging/__init__.py", line 1056, in info
self._log(INFO, msg, args, **kwargs)
File "/usr/lib/python2.6/logging/__init__.py", line 1172, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
File "/usr/lib/python2.6/logging/__init__.py", line 1147, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
File "/usr/lib/python2.6/logging/__init__.py", line 252, in __init__
self.levelname = getLevelName(level)
RuntimeError: maximum recursion depth exceeded
我究竟做错了什么?