This project is archived and is in readonly mode.
Setting ActiveRecord::Base.logger is not effective
Reported by Doug Daniels | June 10th, 2010 @ 02:15 AM | in 3.0.2
I'm trying to use ActiveRecord outside of Rails, and setting the ActiveRecord::Base.logger doesn't seem to work. I think it has something to do with the Rails LogSubscriber being used to print out log messages from ActiveRecord now, and that LogSubscriber being hardcoded to Rails.logger.
Here's the code:
require 'rubygems'
require 'logger'
logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG
require 'active_record'
ActiveRecord::Base.logger = logger
pool = ActiveRecord::Base.establish_connection(
:adapter => 'postgresql',
:database => 'mortar_development',
:pool => 5,
:username => 'postgres',
:password => 'postgres123',
:host => 'localhost'
)
cx = ActiveRecord::Base.connection
# you will see the exception from the connection adapter, but won't see the SQL it tried to run
res = cx.select_all("select * from nonsense_table")
Comments and changes to this ticket
-
Doug Daniels June 10th, 2010 @ 03:06 PM
I think it's b/c I needed to use the Railties require instead of the straight require:
require 'active_record/railtie'
Seems like you can't run it directly w/o Railties.
-
José Valim June 22nd, 2010 @ 05:06 PM
- Milestone cleared.
- Assigned user set to José Valim
-
Repository June 24th, 2010 @ 12:27 PM
- State changed from new to resolved
(from [6788db824ab732b13493a9d702dd8fb89fa153c8]) Move Rails::LogSubscriber to ActiveSupport::LogSubscriber, allowing frameworks like ActiveRecord and ActiveResource to log outsude Rails::Application [#4816 state:resolved] http://github.com/rails/rails/commit/6788db824ab732b13493a9d702dd8f...
-
Prem Sichanugrist (sikachu) June 24th, 2010 @ 05:25 PM
- State changed from resolved to open
José, after you have moved the
Rails::LogSubscriber
toActiveSupport::LogSubscriber
, seems like you left out one obsolete test case. I've attached the patch to remove it, and it should make the railtie_test to pass again. -
Repository June 24th, 2010 @ 07:21 PM
- State changed from open to resolved
(from [974196b0910924d08640703cc558c48ca049246a]) Remove obsolete test case, since we have move Rails::LogSubscriber to ActiveSupport::LogSubscriber in [6788db824ab732b13493a9d702dd8fb89fa153c8] [#4816 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/974196b0910924d08640703cc558c4...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 4816 Setting ActiveRecord::Base.logger is not effective (from [6788db824ab732b13493a9d702dd8fb89fa153c8]) Move Ra...
- 4816 Setting ActiveRecord::Base.logger is not effective (from [974196b0910924d08640703cc558c48ca049246a]) Remove ...