How can I disable the SQL logging which occurs in developmen

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

On May 26, 12:46 am, “Greg H.” [email protected]
wrote:

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

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.rbfile (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 I.
→ 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?

========================================
g$ ruby script/server
=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
************ IN RAILS - initialize_logger ************

  • configuration.log_path = script/…/config/…/log/development.log
  • configuration.log_level.to_s.upcase = DEBUG
  • Loglevel(end) = 0
    => Call with -d to detach
    => Ctrl-C to shutdown server
    ** Starting Mongrel listening at 0.0.0.0:3000
    ** Starting Rails with development environment…
    ******* ENVIRONMENT.RB *******
  • config.log_level = info
    ******* DEVELOPMENT.RB ******* ← I set it a 2nd time to be sure
  • config.log_level = info
    ************ IN RAILS - initialize_logger ************
    ******* DEVELOPMENT.RB ******* ← seems to go back into
    here a
    2nd time during startup
  • config.log_level = info
    ** Rails loaded.
    ** Loading any Rails specific GemPlugins
    ** Signals ready. TERM => stop. USR2 => restart. INT => stop (no
    restart).
    ** Rails signals registered. HUP => reload (without restart). It might
    not
    work well.
    ** Mongrel available at 0.0.0.0:3000
    ** Use CTRL-C to stop.

****** ApplicationController (before mannually setting level):
logger.level= 0 ← this is after I click on the URL and it
enters the controller

  • ApplicationController: logger.level = 1
    [2007-05-27 08:34:10] INFO
    =====================================

On 5/27/07, Greg H. [email protected] wrote:

========================================
g$ ruby script/server
=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000

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

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

----------- development.rb ---------

Settings specified here will take precedence over those in

config/environment.rb

config.cache_classes = false
config.whiny_nils = true
config.breakpoint_server = true

Show full error reports and disable caching

config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_view.cache_template_extensions = false
config.action_view.debug_rjs = true

config.action_mailer.raise_delivery_errors = true # TESTING ONLY
config.action_controller.consider_all_requests_local = false
config.action_mailer.delivery_method = :test

puts “******* DEVELOPMENT.RB *******”
config.log_level = :info
puts " - config.log_level = #{config.log_level}"

Thanks
Greg

Does anyone know of a fix for this when running Mongrel? I have the
exact same problem. Trying to disable logging in development while using
Mongrel doesn’t do anything. Everything is still logged.

Greg H. wrote:

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 A. wrote:

Does anyone know of a fix for this when running Mongrel? I have the
exact same problem. Trying to disable logging in development while using
Mongrel doesn’t do anything. Everything is still logged.