Closed
Description
Migrated issue, originally created by Anonymous
(original reporter: jonathan) The FAQ on logging
http://docs.sqlalchemy.org/en/rel_0_8/faq.html?highlight=logging#how-do-i-configure-logging
sent me to the Engine logging docs:
http://docs.sqlalchemy.org/en/rel_0_8/core/engines.html#dbengine-logging
I wanted to suggest this addition to the docs :
Sometimes you might want to disable existing query logging for certain
statements, such as when you are inserting a BLOB or large TEXT value.
An easy way to accomplish this is to wrap your query in a pair of statements
that toggle the disabled
attribute of the logger.
In the example below, note that the logger needed to disable already-enabled
query logging is sqlalchemy.engine.base.Engine
, and not the
sqlalchemy.engine
logger mentioned above.
import logging
logging.getLogger('sqlalchemy.engine.base.Engine').disabled = True
... execute query ...
logging.getLogger('sqlalchemy.engine.base.Engine').disabled = False
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
sqlalchemy-bot commentedon Oct 11, 2013
Michael Bayer (@zzzeek) wrote:
why don't we fix logging not to log out the full expanse of long binary/text fields ? we've already made similar enhancements long ago regarding long parameter sets.
the doc suggestion is a little bit of a very specific recipe.
sqlalchemy-bot commentedon Oct 11, 2013
Michael Bayer (@zzzeek) wrote:
though for FAQ, its OK sure. though logging should work better I think.
sqlalchemy-bot commentedon Oct 11, 2013
Anonymous wrote:
(original author: jonathan) Limiting the size of these fields logging is a much better idea.
It took me a while to dig out this general approach, and it seemed like a natural "need" by the current system... and also not in-line with the current docs. ( I did not expect the logger path to be different like that, though it does make sense ).
My dev box uses SqlAlchemy as the message broker for Celery Resizing (it's handled by Redis on Production ). All of the sudden during some tests, I'm starting to see a 1.9MB jpeg converted into b64 and piped into an INSERT statement on sqlalchemy. Not fun.
sqlalchemy-bot commentedon Oct 12, 2013
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Dec 30, 2013
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Apr 14, 2014
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Apr 14, 2014
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jul 5, 2014
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Aug 25, 2014
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Apr 27, 2015
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Feb 17, 2016
Michael Bayer (@zzzeek) wrote:
logging, exception, and
repr()
purposes now truncate very largescalar values within each collection, including an
"N characters truncated"
notation, similar to how the display for large multiple-parameter sets
are themselves truncated.
fixes fix logging to truncate large textual/binary values #2837
→ 591e0cf
sqlalchemy-bot commentedon Feb 17, 2016
Changes by Michael Bayer (@zzzeek):
1 remaining item