I have a application which receives large number of requests, and to reduce log file size I want to remove some logs.
One of the logs that I am trying to remove is :
I, [2015-09-09T19:01:01.372374 #10897] INFO -- : Processing by Api::V1::MyAPIController#show as JSON
Basically this log shows to which controller actions the request is getting routed to. I want to remove this log. Is it possible to remove this specific log or change it's log level to debug. Please provide a way to remove this log, as this log by itself provides little information but is taking up considerable disk space.
Thanks for help,
The simplest way to cut output is to change log_level. In your config/environments/production.rb file locate line:
config.log_level = :debug
and change debug to info, warn, error, or fatal.
http://guides.rubyonrails.org/debugging_rails_applications.html#log-levels
Update To silence only routing logs, we can use silencer gem.
In production.rb
require 'silencer/logger'
config.middleware.swap Rails::Rack::Logger, Silencer::Logger, :silence => [%r{^/}]
This will silence all routing logs by replacing Rails::Rack::Logger with silencer on all routes.
More info on silencer configuration can be found here.
Related
I am using the web_console gem and I would like to add some IPs to the whitelist. For reasons that would probably go to far to explain, can't simply add something to the config/application.rb or config/environments/development.rb. However I can create an initializer config/initializers/.
I simple tried this in config/initializers/99-webconsole.rb, but while the file is loaded (--> debug message is shown), the web console does not seem to pick up my settings.
Rails.application.configure do
config.web_console.whitelisted_ips = '10.10.0.0/16'
p "Debug: this is loaded."
end
I assume it's related to some kind of race condition? Providing the same line in config/environments/development.rb works, but as said, I sadly can not change that file.
Based on this code https://github.com/rails/web-console/blob/e3dcf4c588af526eafcf1ce9413e62d846599538/lib/web_console/railtie.rb#L59
maybe there is a code in your initializer that configuring config.web_console.permissions, so your whitelisted_ips config is ignored
whitelisted_ips is also deprecated
and have you checked that you are using v4.2.0, the permissions was buggy and fixed by this commit https://github.com/rails/web-console/commit/6336c89385b58e88b2661ea3dc42fe28651d6296
When I browse the site I get:
We're sorry, but something went wrong.
as I've seen its a 500.html file, so its some internal server error, but how can I make display those errors?
I've tried this:
1) putting ENV['RAILS_ENV'] ||= 'development'in environment.rb, but nothing happened
2) config.log_level = :any, then looked at the production.log, but there is not 500 errors
Or what I need to write in the 500.html to see errors?, or just display it no matter how.
Your log files (wherever they're written) should contain your errors.
If you still like to view the errors in the browser you could change the following in your environment/production.rb (but consider it as a temporary work-around). Make sure to switch it back.
config.consider_all_requests_local = true
i made a distribuited real-time system in RoR, it's compose by 2 machine.
PC A:
take images from a Camera and send these to the second PC. So this machine send every second an http request with the image in the params.
PC B - the server:
save the image in a database.
My problem is that the log file become too big because log even the params string.
How can i set the logger to truncate the params? or simply remove it?
sorry for my bad english..... i hope that someone can help me.
Bye
Davide Lentini.
To specifically remove certain params from the logs you can set the config.filter_parameters in application.rb like this:
config.filter_parameters += [:parameter_name]
This will replace the value of the filtered parameter with "[FILTERED]".
You can set the log level to be less verbose.
See the rails guide on debugging.
So for your entire application (in development), add this to config/environments/development.rb:
config.log_level = :warn # In any environment initializer, or
Or, to change the logging level directly in your application:
Rails.logger.level = 0 # at any time
I use a pretty old rails version which is 2.3.2 because of legacy project.
I set global log_level to :debug in our rails app. But since we also use Rails.cache the log file are full of annoying lines such as
Cache read: ...
Cache miss: ...
I want to just suppress these but not affect other 'more useful' info such as SQL logging.
How to do that?
Well, after initializing your cache store (in the example below, I use memory store) in your specific environment.rb file, you can redirect cache_store's log to a separate file and also tweak the logger level:
config.cache_store = ActiveSupport::Cache::MemoryStore.new(:expires_in => 5.minutes)
config.cache_store.logger = Logger.new("#{Rails.root}/log/#{ENV['RAILS_ENV']}_cache.log")
config.cache_store.logger.level = Logger::INFO
In addition to that, the cache store has a method called silence! that will turn off the logger :-|
config.cache_store.silence!
With the new caching options in Rails 2.1 i get nice entires in my log along the lines of
Cached fragment hit: views/homepage (0.16549)
However they are logged at the :debug level, which is the same level as the SQL output. I want to be able to disable the SQL output, and still see the cache info. How can I do this
well you could instantiate a specific logger for ActiveRecord and set it's log level to :info while leaving the default logger at debug ...
ActiveRecord::Base.logger = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}_database.log")
ActiveRecord::Base.logger.level = Logger::INFO # should set the log_level to info for you
from http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging
or you could reopen AbstractAdapter and override the log(sql,name) method so it does nothing
http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/AbstractAdapter.html#M001242