Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#21484 closed Bug (fixed)

Document that SQL logging does not include "framework level" queries

Reported by: Brian May Owned by: nobody
Component: Documentation Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As discussed here https://docs.djangoproject.com/en/dev/topics/logging/ django supports logging of raw SQL queries. "For example, every SQL statement executed by a request is logged at the DEBUG level to this logger."

However, at least for mysql, this doesn't include initialization or session management SQL queries.

Using wireshark I see a number of extra queries, that are never logged, like:

SET NAMES utf8
set autocommit=0
SET SQL_AUTO_IS_NULL = 0
set autocommit=1
set autocommit=0
rollback
set autocommit=1

I assume "commit" is also on this list, however not part of this test.

Being able to see all the queries is important in order to debug obscure problems.

Thanks

Attachments (1)

21484.diff (1.2 KB ) - added by Tim Graham 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by Tim Graham, 11 years ago

I think for most use cases this would just add more noise to the logs. You can always turn on query logging at the database level if you need it. I'll leave this open for a second opinion and perhaps we can make a documentation update to note this limitation if we don't change the behavior.

comment:2 by Aymeric Augustin, 11 years ago

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

In my opinion, the SQL logger aims at providing "application-level" debugging. It answers the question "what queries does my application emit?". The queries you're mentionning are "framework-level". If your question is "what queries does my database receive?", like Tim, I suggest turning on the database's query logging.

comment:3 by Tim Graham, 11 years ago

Has patch: set
Summary: sql logging incompleteDocument that SQL logging does not include "framework level" queries

by Tim Graham, 11 years ago

Attachment: 21484.diff added

comment:4 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 4d8d76e7a89858932b6f4f280a0ebf4cf94ab4b7:

Fixed #21484 -- Documented that SQL logging does not include "framework level" queries.

comment:5 by Tim Graham <timograham@…>, 11 years ago

In a228545026e30d3223b3fbb13a262b5e005101ae:

[1.6.x] Fixed #21484 -- Documented that SQL logging does not include "framework level" queries.

Backport of 4d8d76e7a8 from master

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