log4r

How can I define my own levels in log4r without a conflict with other log4r-loggers?

邮差的信 提交于 2020-01-03 05:42:51
问题 I can define my own log-levels with log4r: require 'log4r' require 'log4r/configurator' # This is how we specify our levels Log4r::Configurator.custom_levels "Foo", "Bar", "Baz" log = Log4r::Logger.new('custom levels') p log.levels #-> ["ALL", "Foo", "Bar", "Baz", "OFF"] log.add Log4r::StdoutOutputter.new('console') puts log.foo? #-> true log.foo "This is foo 1" log.level = Log4r::Bar puts log.foo? #->false log.foo "This is foo 2" The log4r-documentation says: Also, custom levels should be

Ruby: Uninitialized constant Log4r::DEBUG (NameError) problem

回眸只為那壹抹淺笑 提交于 2020-01-01 16:45:13
问题 While using log4r in Ruby, I wrote a configuration file similar to the following: require 'rubygems' require 'log4r' require 'log4r/outputter/datefileoutputter' SERVICE_LOG = { :log_name => 'service', :log_file => 'service.log', :log_level => Log4r::DEBUG, :message_pattern => "[%-5l %d] %C: %M", :date_pattern => "%Y-%m-%d %H:%M:%S" } when I ran it, it threw out the following exception: C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `load

rails 4 log4r server.rb:78:in `start': undefined method `formatter'

ε祈祈猫儿з 提交于 2019-12-13 13:06:30
问题 I have been researching this topic for far too long now, so I have to post this. I have a few applications running this setup and one of them completely borks on rails startup (rails s). They are both configured nearly the exact same, but I can not seem to find the needle in the haystack here. Does anyone have any pointers on how to find this issue? setup based on: http://blog.mmlac.com/log4r-for-rails/comment-page-1/#comment-1731 when I try to run rails s: => Booting WEBrick => Rails 4.0.0

How can I test logger-messages with MiniTest?

﹥>﹥吖頭↗ 提交于 2019-12-10 14:37:45
问题 I have an application and I want to test if I get correct messages from my logger. A short example (you may switch between log4r and logger): gem 'minitest' require 'minitest/autorun' require 'log4r' #~ require 'logger' class Testlog < MiniTest::Test def setup if defined? Log4r @log = Log4r::Logger.new('log') @log.outputters << Log4r::StdoutOutputter.new('stdout', :level => Log4r::INFO) else @log = Logger.new(STDOUT) @log.level = Logger::INFO end end def test_silent assert_silent{ @log.debug(

Is Ruby's stdlib Logger class thread-safe?

跟風遠走 提交于 2019-12-09 02:08:25
问题 In short, is the standard library Logger class in Ruby thread-safe? Only useful info Google turned up was someone on a forum saying it "seems" thread-safe. And I don't feel like spending time testing a logger to try to figure out if it is or not. For the time being I'm using log4r which is thread-safe, but it's overkill if the standard library already does it. 回答1: A quick look at logger.rb reveals code such as the following: def write(message) @mutex.synchronize do if @shift_age and @dev

Undefined Method Formatter for Log4r in RAILS 4.0

℡╲_俬逩灬. 提交于 2019-12-07 05:49:21
问题 I am getting this error after upgrading Rails from 3.1.2 to 4.0. When launching my server with rails s I got stuck with the following error C:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:78:in `start': undefined method `formatter' for #<Log4r::Logger:0x26dd908> (NoMethodError) I have been on the Log4r site but haven't got any infor;ation about a bug when upgrading Rails. Does anyone have any idea where this bug comes from. Thank you! 回答1: The method