On Nov 19, 2013, at 12:39 PM, Jon Nelson <[email protected]> wrote:

> Greetings, once more!
> 
> I'm having some trouble with logging.
> Before I call any sqlalchemy functions or bits (but after sqlalchemy
> is imported), I use logging.config.fileConfig(...) to configure the
> logging.
> 
> The file is set to configure sqlalchemy at NOTSET and
> sqlalchemy.engine and sqlalchemy.pool as INFO.
> 
> The sequence goes like this:
> 
> logging.config.fileConfig(...)
> sqlalchemy_setup_create_engine_and_models_etc()
> do_other_stuff
> 
> 
> the problem is, the logging for sqlalchemy (and the rest of the app)
> is broken *unless* I call logging.config.fileConfig(....) *after* the
> sqlalchemy setup.
> 
> What's likely to be going on here?

SQLAlchemy will affect the config of logging only if any of the “echo” flags 
are used - the effect of echo=True is that it calls logging.basicConfig().  
This config will occur in addition to the config that you do with fileConfig(), 
so it shouldn’t be *broken*, you’d see double logging.

If no echo flags are set, then SQLAlchemy just uses it’s loggers with whatever 
level has been set.  However, for performance reasons, the Connection will 
check logging levels when it is first created and log conditionally based on 
that flag, so you won’t see logging for any Connections that have been created 
before the logging levels were set.  but this sounds like the opposite of what 
you’re seeing.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to