python - Logging not showing in console during django tests -
i trying simple tests in django. have setup django logging system in settings file. when run test won't print debug messages on console. happens when run tests manage.py test command. if use ide's run command prints messages normally. logging setup following
logging = { 'version': 1, 'disable_existing_loggers': true, 'formatters': { 'verbose': { 'format': '%(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', }, 'console': { 'level':'debug', 'class': 'logging.streamhandler', 'formatter': 'simple', }, }, 'loggers': { 'django': { 'handlers': ['console', ], 'propagate': true, 'level': 'debug' }, 'payments_system': { 'handlers': ['console', ], 'propagate': true, 'level': 'debug' } } } logging based on django's website example. how can make messages appear in console when run tests manage.py?
i have django logging set log file, this:
'handlers': { 'file': { 'level': 'debug', 'class': 'logging.filehandler', 'filename': '/path/to/django/debug.log', }, }, when run tests python manage.py test, logs go file.
since you're using console handler, logs should going stdout, being captured filtered test code. try using filehandler instead. refer first example under configuring logging more details.
Comments
Post a Comment