Silence logging altogether for certain actions?


#1

Hi, I am looking for a way to silence logging altogether for certain
actions. Our app talks to other servers and session components, and
our logs get filled up with this nonsense, even in Production mode. I
want to completely silence all the automatic logging by Rails of the
basic request parts: method, params, etc.

I’ve seen logger.silence, but that doesn’t appear to get rid of the
basic request chatter. Any ideas?

Processing ServersController#register to xml (for 127.0.0.1 at
2009-04-15 20:52:17) [POST]
Parameters: {“server”=>{“uname_node_name”=>“domU”,
“server_type”=>“FLS”, “management_port”=>“11054”,
“service_address”=>“1.2.3.4”, “uname_version”=>"#2 SMP Tue Feb 19
10:51:53 EST 2008", “service_port”=>“10054”,
“management_address”=>“1.2.3.4”, “uname_sysname”=>“Linux”,
“max_clients”=>“2000”, “current_clients”=>“2”,
“instance_uuid”=>“5b7a3804”, “server_version”=>“2.1.1/edge (r
2009-04-01 11:13:21) [i686-linux]”, “uname_domain_name”=>"(none)",
“uname_release”=>“2.6.18-xenU-ec2-v1.0”, “uname_machine”=>“i686”},
“server_stats”=>{“cpu_sys”=>“0.000000”, “cpu_nice”=>“0.000000”,
“cpu_idle”=>“0.000000”, “cpu_user”=>“0.000000”}}
Rendering servers/register
Completed in 79ms (View: 1, DB: 4) | 200 OK [https://
ec2.compute-1.amazonaws.com/servers/register.xml]

Processing SessionsController#ping to xml (for 127.0.0.1 at 2009-04-15
20:52:39) [POST]
Completed in 16ms (View: 0, DB: 2) | 200 OK [https://
ec2.compute-1.amazonaws.com/session/ping.xml]

Processing SessionsController#ping to xml (for 127.0.0.1 at 2009-04-15
20:52:41) [POST]
Completed in 6ms (View: 0, DB: 2) | 200 OK [https://
ec2.compute-1.amazonaws.com/session/ping.xml]

Processing ServersController#register to xml (for 127.0.0.1 at
2009-04-15 20:52:47) [POST]
Parameters: {“server”=>{“uname_node_name”=>“domU”,
“server_type”=>“FLS”, “management_port”=>“11054”,
“service_address”=>“1.2.3.4”, “uname_version”=>"#2 SMP Tue Feb 19
10:51:53 EST 2008", “service_port”=>“10054”,
“management_address”=>“1.2.3.4”, “uname_sysname”=>“Linux”,
“max_clients”=>“2000”, “current_clients”=>“2”,
“instance_uuid”=>“5b7a3804”, “server_version”=>“2.1.1/edge (r
2009-04-01 11:13:21) [i686-linux]”, “uname_domain_name”=>"(none)",
“uname_release”=>“2.6.18-xenU-ec2-v1.0”, “uname_machine”=>“i686”},
“server_stats”=>{“cpu_sys”=>“0.000000”, “cpu_nice”=>“0.000000”,
“cpu_idle”=>“0.000000”, “cpu_user”=>“0.000000”}}
Rendering servers/register
Completed in 38ms (View: 1, DB: 24) | 200 OK [https://
ec2.compute-1.amazonaws.com/servers/register.xml]


#2

Any ideas?


#3

One way that might meet your needs is to just up the log level
temporarily:


bak_log_level = logger.level
begin
logger.level = :fatal # or some other uppper log level …
# stuff you want to perform but restrict logging …

rescue

ensure
logger.level = bak_log_level
end

See
http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels

Jeff


#4

(re-posted) One way that might meet your needs is to just up the log
level temporarily:


bak_log_level = logger.level
begin
logger.level = Logger::ERROR # or some other uppper log
level …
# stuff you want to perform but restrict logging …

rescue

ensure
logger.level = bak_log_level
end

See
http://guides.rubyonrails.org/debugging_rails_applications.html#log-l

Jeff