Toby Bradshaw wrote:
>
> Hi,
>
> Succintly: What's the correct way to set up logging in SQLAlchemy 0.5.2 ??
>
> The docs say simply set the logger level correctly. However I notice in
> the source that most classes make a check on _should_log_info (which is
> set during __init__) before deciding whether to call the logger. This
> has the effect of ignoring changes to the log level made after the
> object was created.
>
> Specifically, this code does not work as expected:
>
> _engine = create_engine(config.options.orm_url)
> _engine.echo = False
>
> logging.getLogger("sqlalchemy.engine").setLevel(logging.DEBUG)
> logging.getLogger("sqlalchemy.engine").isEnabledFor(logging.DEBUG) #
> == True but logging still doesn't happen
>
> So is there a solution to this? It doesn't work to simply set the log
> level before creating the engine since 'No handlers could be found for
> logger "sqlalchemy.engine.base.Engine.0x...bf34"'
you can set echo=True or False anytime you want - that flag propagates the
required state to the engine. Doing setLevel() etc. you have to do
before any SQLAlchemy code is imported. Also you should not mix the
usage of echo=True with straight Python logging configuration.
the flags are there because the overhead of the standard logging module is
enormous, especially isEnabledFor().
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---