I'm using following code to configure logging in my Ruby on Rails application:
environment.rb:
Rails.logger = Logger.new(STDOUT) class Logger def format_message(severity, timestamp, progname, msg) "#{timestamp.to_formatted_s(:db)} #{severity} #{msg}\n" end end
I'm trying to set the logging level to warn now using
config.log_level = :warn
in my production.rb, but it doens't seem to work. Am I missing something here?
If I put Rails.logger.level = 4 in my environment.rb, it does seem to work. But I would like to configure things in my environment initializers.
To change log levels as a root user, perform the following: To enable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=DEBUG) To disable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=INFO)
What is a logging level? A logging level is a way of classifying the entries in your log file in terms of urgency. Classifying helps filter your log files during search and helps control the amount of information in your logs. Sometimes, categorizing may require you to balance storage use.
According to the official documentation, you should be using:
config.log_level = :warn # In any environment initializer, or Rails.logger.level = 0 # at any time
If neither of those work for you, try:
config.log_level = Logger::WARN
And if that doesn't work, try:
config.logger.level = Logger::WARN
Note: The final method appears to be conflating the two official strategies, but works in some situations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With