Opened 14 years ago

Closed 14 years ago

Last modified 13 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: no UI/UX: no

Description

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 14 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Russell Keith-Magee, 14 years ago

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 by John Paulett, 14 years ago

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

by John Paulett, 14 years ago

Attachment: 15527.diff added

comment:3 by Malcolm Box, 14 years ago

Cc: Malcolm Box added

comment:4 by Russell Keith-Magee, 14 years ago

Triage Stage: AcceptedReady for checkin

comment:5 by Russell Keith-Magee, 14 years ago

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 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

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