I'm having difficulty getting the desired behavior at the intersection of the django test runner, i.e. from django.test import TestCase
and the logging solution.
my logger is set up and works in other areas with something like this
import logging
logger = logging.getLogger(__name__)
logger.warning("duck!")
so when running the Django app, I see the message and metadata as I expect; however, the trouble is that these log lines do not show up in any location I am aware of when running the unit tests, i.e. django-admin run test
I want to be able to run tests and see the log output, ideally in STDOUT, and presumably set the output log levels so that tests show those...
my settings vis. logging:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'root': {
'level': 'ERROR',
'handlers': ['sentry', 'console'],
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s '
'%(process)d %(thread)d %(message)s'
},
},
'handlers': {
'sentry': {
'level': 'WARNING', # To capture more than ERROR, change to WARNING, INFO, etc.
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler',
'tags': {'custom-tag': 'x'},
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django.db.backends': {
'level': 'ERROR',
'handlers': ['console'],
'propagate': False,
},
'raven': {
'level': 'WARNING',
'handlers': ['console'],
'propagate': False,
},
'sentry.errors': {
'level': 'DEBUG',
'handlers': ['console'],
'propagate': False,
},
'celery': {
'handlers': ['console'],
'level': 'WARNING',
'proagate': True,
},
},
}