Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#15527 closed (fixed)

django.db logger only works when DEBUG=True

Reported by: Malcolm Box Owned by: John Paulett
Component: Documentation Version: 1.3-beta
Severity: Keywords: logging
Cc: john@…, Malcolm Box Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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.

Attachments (1)

15527.diff (597 bytes) - added by John Paulett 7 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by Russell Keith-Magee

Component: Database layer (models, ORM)Documentation
milestone: 1.3
Triage Stage: UnreviewedAccepted

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.

comment:2 Changed 7 years ago by John Paulett

Cc: john@… added
Has patch: set
Owner: changed from nobody to John Paulett

Changed 7 years ago by John Paulett

Attachment: 15527.diff added

comment:3 Changed 7 years ago by Malcolm Box

Cc: Malcolm Box added

comment:4 Changed 7 years ago by Russell Keith-Magee

Triage Stage: AcceptedReady for checkin

comment:5 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

In [15897]:

Fixed #15527 -- Added a explanatory note about the SQL debug log. Thanks to boxm for the report, and jpaulett for the draft patch

comment:6 Changed 7 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

Note: See TracTickets for help on using tickets.
Back to Top