Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15527 closed (fixed)

django.db logger only works when DEBUG=True

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

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 jpaulett 3 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 3 years ago by russellm

  • Component changed from Database layer (models, ORM) to Documentation
  • milestone set to 1.3
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 3 years ago by jpaulett

  • Cc john@… added
  • Has patch set
  • Owner changed from nobody to jpaulett

Changed 3 years ago by jpaulett

comment:3 Changed 3 years ago by boxm

  • Cc boxm added

comment:4 Changed 3 years ago by russellm

  • Triage Stage changed from Accepted to Ready for checkin

comment:5 Changed 3 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

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 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.