Logging is one of the most important tools when troubleshooting and debugging a Django application.
If you're following the Twelve-Factor App methodology for your application, then you'll want to send your logs to Stdout.
The Django documentation doesn't provide an example of how to do this easily so let's go through how to achieve that.
In your Django 'settings.py' add the following configuration.
This will result in all logs of info level or above going to Stdout. It's as easy as that.
Next, of course, you'll want a centralised place to read your logs. We use papertrail for this. Here are some useful links for that:
- How to send your Docker logs to papertrail
- How to send your Django logs directly to papertrail. (Note that this method goes against the Twelve-Factor App methodology)
If you have any other tips or tricks to share, we'd love to hear them in the comments!