Gainster
Gainster

Reputation: 5631

How disable automatic logging in ruby

I am using logger to log the values of the variables for debuging. Because automatic debugging logs it is diffcult to find values

How to slient automatic logging?

Upvotes: 2

Views: 1965

Answers (2)

thesis
thesis

Reputation: 2565

You can configure Rails logger in config/application.rb. config.log_level defines the verbosity of the Rails logger. The available log levels are: :debug, :info, :warn, :error, :fatal.

Example:

config.log_level = :warn

Also read information about Logger: http://guides.rubyonrails.org/debugging_rails_applications.html#the-logger

Upvotes: 1

x1a4
x1a4

Reputation: 19475

You can't turn if off completely while still having your log messages go to the log, but there are a couple of solutions I can think of:

  1. Set logging to a very high level (like :fatal), then log your messages at that level. There shouldn't be much noise in the log at that log level.

  2. Prefix your log messages with a unique identifier, e.g. MYSTUFF, then grep for that when you're tailing the log: tail -f log/production.log | grep MYSTUFF. Doing it this way means you don't have to change your log configuration.

Upvotes: 2

Related Questions