From: Zach Moazeni Date: 2006-01-30T06:09:27+09:00 Subject: Question about Lo4R Hello, I'm having an issue with a Formatter for Log4R. I'm trying to use the %c format directive to display the Line Number of the file and for some reason it keeps throwing an error. I'm using Ubuntu Breezy 5.1, Ruby 1.8.3, and Log4R 1.0.5. Is anyone else having any similar issues? Error Msg : (eval):2:in `format': undefined method `[]' for nil:NilClass (NoMethodError) from /usr/local/lib/site_ruby/1.8/log4r/outputter/outputter.rb:118:in `format' from /usr/local/lib/site_ruby/1.8/log4r/outputter/outputter.rb:108:in `canonical_log' from /usr/local/lib/site_ruby/1.8/log4r/outputter/outputter.rb:108:in `synch' from /usr/local/lib/site_ruby/1.8/log4r/outputter/outputter.rb:128:in `synchronize' from /usr/local/lib/site_ruby/1.8/log4r/outputter/outputter.rb:128:in `synch' from /usr/local/lib/site_ruby/1.8/log4r/outputter/outputter.rb:108:in `canonical_log' from (eval):3:in `debug' from (eval):8:in `debug' from (eval):8:in `each' from (eval):8:in `debug' from ./blah.rb:37:in `happy' from ./blah.rb:42 Here is the small snipbit of code require 'log4r' include Log4r class MyClass def initialize puts('init') @my_log = Logger.new 'myLog' formatter = PatternFormatter.new( #:pattern => "%l[%d] %t %1M") :pattern => "%5l [%d] %t: %.25M", :date_pattern => "%H:%M:%S") @my_log.outputters = FileOutputter.new('myLog', :filename => "log_file", :trunc => false, :formatter => formatter) puts(Kernel.caller[0].to_s) end protected def logger puts("got logger") @my_log end end class MyChild < MyClass def initialize super end def happy logger.debug('happy') end end c = MyChild.new c.happy I'd appreciate any and all input. Thanks! -Zach