Well problem worked around by using echo=True for dev builds and thanks 
for your suggestion.

Your statement:

> Doing setLevel() etc. you have to do
before any SQLAlchemy code is imported

Unfortunately doesn't seem to help since the logging module later reports:

"No handlers could be found for
logger "sqlalchemy.engine.base.Engine.0x...bf34""

and logging still doesn't seem to work.

This combined with the fact that echo and logging aren't recommended to be used 
together suggests that, at least by following the instructions on the docs 
site, SQLAlchemy logging through the python logging wont in fact work for any 
other configuration other than the default one.

However.. I know the turbogears guys have got this working so perhaps I should 
go dig around there and see how they've managed to do it.

Thanks again.

t o b e



Michael Bayer wrote:
> 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().
>
>
> >
>   

-- 
t o b e
--
A truly clever developer will create code so easy to understand that a less 
than average developer could debug it.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to