Debug Levels Rails - The level ":debug" show all logs. I want ONLY ERRORS. Is it possible?

3.6k views Asked by At

I have an app in AWS Ec2 and I want to see the errors ( 500, 502, 50x, 403, 404 etc. ) ina log file.

The file config / environments / production.rb

Have the code:

config.log_level = :debug

I tried to change this to :warn, :info, :error, :fatal. Really this values shows ONLY ERRORS, but the information is very limited.

The value :debug shows many datails, but... Shows all logs too...

I am seeing the erros log here:

EC2 ROOT: cd /var/log/nginx
CMD: tail -f error.log

There are another log folder, inside the app, here:

{appfolder}/current/log/production.log

But this file is empty. The logs are not being saved here.

Some informations:

ruby -v: 2.2.2p95
rails -v: 4.2.1
OS: Ubuntu 14.04.2 LTS

Tks everyone.

2

There are 2 answers

0
MZaragoza On BEST ANSWER

Here is the the official documentation,

in your #config/environments/production.rb you can add/change the log_level like this

  # Use the lowest log level to ensure availability of diagnostic information
  # when problems arise.
  # :debug, :info, :warn, :error, and :fatal
  config.log_level = :error

I hope that this helps

Happy Hacking

0
Sebastian On

Check Logger class http://ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html. Just use log level suitable for you.