Reputation: 9956
I'm using a Ruby gem that utilizes the Logger
class.
Is there a way to set log levels globally like in log4j with an .xml
or .properties
file?
I don't want the output to be written at all. My concern is that printing all those logging statements drains performance.
P. S.: It's just a simple script, I'm not using Ruby on Rails.
Upvotes: 1
Views: 1444
Reputation: 527
Because the gem you're using is kind enough to expose the logger as a attr_accessor, you can simply do this:
some_server = Server.new
some_server.logger.level = Logger::ERROR
Obviously feel free to chose the log level that is appropriate for your environment and application (http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html).
Hope this helps.
Upvotes: 3