Raven SentryHandler suppresses StreamHandler output to file

I have a simple python (non-Django) project where I am trying to bind Raven to a logging setup .

As part of our current setup, we use a simple logging configuration:

import logging
logging.basicConfig(format='long detailed format',
                    level=logging.DEBUG)

Then the result is redirected to the log file; it gives a nice, detailed log that we can view when we need it.

Now we want to add the Raven error log, linking it to our current logging setting so that it alsologging.error triggers , and the message is sent to the Sentry server. Using the following code:

from raven import Client
from raven.conf import setup_logging
from raven.handlers.logging import SentryHandler

raven = Client(environ.get('SENTRYURL', ''), site='SITE')
setup_logging(SentryHandler(raven, level=logging.ERROR))

Errors are successfully sent to Sentry, but now I get only one line of file output:

DEBUG: Configuring Raven for host: <DSN url>

- logging.debug logging.error - .

setup_logging, , Sentry. ?

+5
1

. - , :

logging.root.removeHandler(logging.root.handlers[0]) # Undo previous basicConfig
logging.basicConfig(format='same long format',
                    level=logging.DEBUG)

, logging.basicConfig , logging.root , , , basicConfig, no-op, , StreamHandler .

basicConfig setup_logging.

+3

All Articles