Forum: Ruby on Rails how can I disable the SQL logging which occurs in developmen

D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2007-05-26 06:48
(Received via mailing list)
Hi - how can I disable the SQL logging which occurs in development mode?
Tks
Ff168162d53e22788d576582b3527e97?d=identicon&s=25 Bill Kocik (Guest)
on 2007-05-26 14:47
(Received via mailing list)
On May 26, 12:46 am, "Greg Hauptmann" <greg.hauptmann.r...@gmail.com>
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
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2007-05-26 23:02
(Received via mailing list)
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
Df4978da52459529e539da4c995918cb?d=identicon&s=25 Zach Inglis // LT3media (Guest)
on 2007-05-26 23:42
(Received via mailing list)
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
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2007-05-27 00:40
(Received via mailing list)
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
=====================================
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2007-05-28 22:45
(Received via mailing list)
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" <xxxxx>)
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
5233478c51a92b6a1a5c970cbf3a42f3?d=identicon&s=25 Isak Hansen (Guest)
on 2007-05-29 13:00
(Received via mailing list)
On 5/27/07, Greg Hauptmann <greg.hauptmann.ruby@gmail.com> 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
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2007-05-29 21:22
(Received via mailing list)
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
79836c5ea26f814c94414f4bc162e2f6?d=identicon&s=25 Robbie Allen (roallen)
on 2009-02-07 14:58
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 Hauptmann 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
79836c5ea26f814c94414f4bc162e2f6?d=identicon&s=25 Robbie Allen (roallen)
on 2009-02-20 12:50
Anyone?

Robbie Allen 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.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.