Question about Lo4R

Z

Zach Moazeni

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
 
T

tsumeruby

Just a note, the ruby included with breezy is not 1.8.3 release. ruby -v
Most people build their own snapshot of ruby. I never trust a distributors
ruby because they 1) keep taking snapshots from a SCM, or 2) make
modifications which break existing code.

Tsume
 
A

Alex Combas

$ cat /etc/lsb-release
DISTRIB_ID=3DUbuntu
DISTRIB_RELEASE=3D5.10
DISTRIB_CODENAME=3Dbreezy
DISTRIB_DESCRIPTION=3D"Ubuntu (The Breezy Badger Release)"

$ ruby -v
ruby 1.8.3 (2005-06-23) [i486-linux]



Just a note, the ruby included with breezy is not 1.8.3 release. ruby -v
Most people build their own snapshot of ruby. I never trust a distributor= s
ruby because they 1) keep taking snapshots from a SCM, or 2) make
modifications which break existing code.

Tsume

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 els= e
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 `forma= t'
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 =3D Logger.new 'myLog'
formatter =3D
PatternFormatter.new(
#:pattern =3D> "%l[%d] %t %1M")

:pattern =3D> "%5l [%d] %t: %.25M",
:date_pattern =3D> "%H:%M:%S")

@my_log.outputters =3D FileOutputter.new('myLog',

:filename =3D> "log_file",
:trunc =3D> false,
:formatter =3D> 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 =3D MyChild.new
c.happy


I'd appreciate any and all input. Thanks!
-Zach
 
T

tsumeruby

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=5.10
DISTRIB_CODENAME=breezy
DISTRIB_DESCRIPTION="Ubuntu (The Breezy Badger Release)"

$ ruby -v
ruby 1.8.3 (2005-06-23) [i486-linux]

Exactly, 1.8.3 was released on 09/21/2005. Somebody took a development
snapshot instead of taking critical patches and declared it the ruby to be
used in Ubuntu Breezy. The people who noticed the version were a bit too late
and Breezy had already been frozen.

Tsume
Just a note, the ruby included with breezy is not 1.8.3 release. ruby -v
Most people build their own snapshot of ruby. I never trust a
distributors ruby because they 1) keep taking snapshots from a SCM, or 2)
make modifications which break existing code.

Tsume

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top