how can I disable the SQL logging which occurs in development mode?

Hi - how can I disable the SQL logging which occurs in development mode? Tks

In production mode you won't see it if that's what you're worried about. But if you want it gone in development mode as well, put this in your config/environments/development.rb file:

config.log_level = :info

If you also want it gone in testing mode, you can put that in config/ environment.rb instead (or put it in both development.rb and test.rb).

By default this is set to :debug, which shows the SQL queries.

-Bill

Tks Bill - seems that the Rails framework debug code can’t easily be switched off itself then in :debug mode.

I’ve had a problem trying to get “config.log_level = :info” working properly & it’s driving me nuts. Any advice would be great (I did post this separately last night but no responses yet).

I have included the line “config.log_level = :info” in my environment.rb file (and it doesn’t occur in development.rb) HOWEVER I keep getting Debug messages coming out in development mode in my development.log file. I have tried this approach in another rails project and it worked fine, however for my main project I’m working on it does not seem to filter out the Debug lines and I keep seeing them.

Any ideas on how to trouble-shoot this?

  • how to check (perhaps through console) what the config.log_level is?
  • other??

Thanks

From what I can gather, you put it in environment.rb and not the sub env files; development.rb, production.rb Make sure that the function with a different result isn’t in development.rb as that’ll over-ride it, and try putting it as the last line in your environment/development.rb

Cheers,

Zach Inglis

→ Blog – http://www.zachinglis.com

→ Company – http://www.lt3media.com

→ Portfolio – http://portfolio.zachinglis.com

I’ve tried all this (thanks), however still no luck. If I override the level in a controller seems to be my only workaround I can see.

I put some logging into the rails code (in the gems area) and it’s as if the level has been set to :info at the configuration stage, but by the time the code enters my controller for the first time the level is at 0. I’m using Locomative, rails v1.2.3, ruby v1.8.5

Any ideas?

PS - Here is a copy of my config files if this helps anyone see where I’m going wrong:

======== environment.rb =========

ENV[‘RAILS_ENV’] ||= ‘production’ require File.join(File.dirname (FILE), ‘boot’)

require ‘plugins/app_config/lib/configuration’

Rails::Initializer.run do |config| puts “******* ENVIRONMENT.RB *******” config.log_level = :info puts " - config.log_level = #{config.log_level}" end

ActiveRecord::Base.default_timezone = :utc LOCALES = {‘en’ => ‘en’, ‘fr’ => ‘fr’}.freeze

ExceptionNotifier.exception_recipients = %w(xxxxxx) ExceptionNotifier.sender_address = %(“Application Error” ) ExceptionNotifier.email_prefix = “[xxxxxx]”

Mail

ActionMailer::Base.smtp_settings = { :address => “xxxxx”,

:port => 25, :domain => “xxxxx”, :user_name => “xxxx”, :password => “xxxx”, :authentication => :login }

class Logger def format_message(severity, timestamp, progname, msg) f_start = 27.chr + ‘[0;34m’ f_end = 27.chr + ‘[0m’ f_start + “[#{timestamp.strftime(”%Y-%m-%d %H:%M:%S")}] #{severity}" + f_end + " #{msg}\n" end end

Try again using webrick. I think there's an issue with logger levels when running mongrel in dev mode.

Isak

You’re exactly correct Isak! Thanks.

The logging functionality worked as it should in webrick. Is seems screwed up in Mongrel. I’ll swap to using webrick in development (and try to find out where/how to let the Mongrel team about this).

Interestingly I noted that with webrick the logging doesn’t come out on the console, but rather I had to open a second iTerm and tail the log file itself. Perhaps there is a “script/server webrick” setting I could use to enable logging to console if I went looking.

Tks Greg

Anyone?

Robbie Allen wrote: