# How can I disable the SQL logging which occurs in developmen

**URL:** <https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144>\
**Category:** Rails\
**Created:** [May 26, 2007, 6:48am UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144 "2007-05-26T06:48:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 26, 2007, 6:48am UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/1 "2007-05-26T06:48:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 26, 2007, 2:47pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/2 "2007-05-26T14:47:00Z")

</div>

On May 26, 12:46 am, “Greg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 26, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/3 "2007-05-26T23:02:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 26, 2007, 11:42pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/4 "2007-05-26T23:42:52Z")

</div>

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](http://www.zachinglis.com)  
â†’ Company – [http://www.lt3media.com](http://www.lt3media.com)  
â†’ Portfolio – [http://portfolio.zachinglis.com](http://portfolio.zachinglis.com)

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 27, 2007, 12:40am UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/5 "2007-05-27T00:40:59Z")

</div>

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](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  
=====================================

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 29, 2007, 1:00pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/6 "2007-05-29T13:00:36Z")

</div>

On 5/27/07, Greg H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ========================================  
> g$ ruby script/server  
> =\> Booting Mongrel (use ‘script/server webrick’ to force WEBrick)  
> =\> Rails application starting on [http://0.0.0.0:3000](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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 29, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/7 "2007-05-29T21:22:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [May 28, 2007, 10:45pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/8 "2007-05-28T22:45:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 7, 2009, 2:58pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/9 "2009-02-07T14:58:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [February 20, 2009, 12:50pm UTC](https://www.ruby-forum.com/t/how-can-i-disable-the-sql-logging-which-occurs-in-developmen/105144/10 "2009-02-20T12:50:24Z")

</div>

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.
