django.db logger only works when DEBUG=True
The default django.db logger only gets the SQL of queries written to it when DEBUG=True.
This limitation is not documented, leading users to expect their query logging to work.
Either the behaviour should be changed to always log (which would be preferred), or the documentation updated to reflect the DEBUG=True limitation.
Justification for always logging, even if DEBUG != True is that it is extremely useful to be able to turn on logging for DB queries on a production system without triggering all the other behaviours that DEBUG=True causes. With the current setup this is impossible. The developer already has control over suppressing the logging if it is unwanted, so nothing is lost by allowing query logging always.
Change History
(7)
Component: |
Database layer (models, ORM) → Documentation
|
milestone: |
→ 1.3
|
Triage Stage: |
Unreviewed → Accepted
|
Cc: |
john@… added
|
Has patch: |
set
|
Owner: |
changed from nobody to John Paulett
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
This was done on purpose. Database queries are a high volume area of the Django API, so having an logging call -- even a logging call that is ignored -- is a performance hit that we didn't want to impose unilaterally.
However, you are correct that this should be documented.