It is important to keep track of the performance of your application. One popular way to do this is to log slow queries. Below is how to do this in Django python. Your logging config will vary depending on how your django app is setup. On simpler django sites it might be in settings.py
This config has two
loggers. One named
django and one named
Loggers are the entry point for the logging system in django. We apply our slow
query logic only to the
django.db.backends handler. After a logger has
dealt with a log it applies any
filters onto it.
Filters provide extra control over logs. We define one filter in the example above. This filter will allow only slow queries to go through, thus we would log slow queries so that the developer can read them later. The filter applies a python lambda inline that will only let logs with a duration > 50 milliseconds pass through.
This config has one handler
console. A handler is a destination for where
the django logs should go. This could be a file writer, stdout, another handler,
If you need help solving your business problems with software read how to hire me.