I am using a simple unit test based test runner to test my Django application.
My application itself is configured to use a basic logger in settings.py using:
<
If you're using pytest:
Since pytest captures log messages and only displays them for failed tests, you typically don't want to disable any logging. Instead, use a separate settings.py file for tests (e.g., test_settings.py), and add to it:
LOGGING_CONFIG = None
This tells Django to skip configuring the logging altogether. The LOGGING setting will be ignored and can be removed from the settings.
With this approach, you don't get any logging for passed tests, and you get all available logging for failed tests.
The tests will run using the logging that was set up by pytest. It can be configured to your liking in the pytest settings (e.g., tox.ini). To include debug level log messages, use log_level = DEBUG (or the corresponding command line argument).