Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use log_level :debug in production on my Rails app

The default for production.rb is:

config.log_level = :info

However, I really like to see the SQL queries and extra logging in my production environment.

Changing the log level to:

config.log_level = :debug

Is this a terribly bad practice? How much overhead does this add to my application to have Rails do this extra logging?

like image 599
dylanjha Avatar asked Jan 21 '14 22:01

dylanjha


People also ask

What log level should be used in production?

The WARN level is the level that should be active in production systems by default, so that only WARN and ERROR messages are being reported, thus saving storage capacity and performance.

Where are rails logs stored?

In a Rails app, logs are stored under the /log folder. In development mode, the development. log file is used & you see log output on the terminal you're running rails server on.

What is the log to check for errors in Rails?

Rails uses six different log levels: debug, info, warn, error, fatal, and unknown. Each level defines how much information your application will log: Debug: diagnostic information for developers and system administrators, including database calls or inspecting object attributes. This is the most verbose log level.

How do I check logs in Ruby on Rails?

If you want to know the current log level, you can call the Rails. logger. level method. This is useful when you want to log under development or staging without flooding your production log with unnecessary information.


2 Answers

It's simply a question of how large a log file you're willing to deal with. I suggest setting it to :debug for a few days, and then decide based on the resulting log sizes. This is a decision that may change day-to-day, based also on what you need debugged, and how many and how verbose your debug statements are.

like image 52
Mori Avatar answered Oct 08 '22 13:10

Mori


For your reference below are some links for rails best practices that I found while Googling:

Best Practices for a Web App Staging Server (on a budget)

http://kpumuk.info/ruby-on-rails/flexible-application-configuration-in-ruby-on-rails/

http://railsware.com/blog/2013/10/16/rails-configuration-in-the-proper-way/

Best practices for Ruby on Rails *feature* deployment?

Here is rails 4 production logging and new features:

http://rubyjunky.com/cleaning-up-rails-4-production-logging.html

Also in other way you can do it with easily by taking back up of production DB on your local machine and test / debug those data in the way that you want.

like image 38
Sumit Munot Avatar answered Oct 08 '22 13:10

Sumit Munot