Forum: Ruby conflict between active record and Log4R

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1ed4bbef573bfc014d32356d53103ca2?d=identicon&s=25 Phil Swenson (philswenson)
on 2005-12-20 01:39
I recently added some activerecord code to a stand-alone application
that uses Log4R.  I'm getting some weird conflicts.

The code below demonstrates one of the problems I see... if you remove
the line : "require_gem 'activerecord'" the code executes fine.  If you
have it in the code you will get the following error:

C:/ruby/lib/ruby/site_ruby/1.8/log4r/logger.rb:109:in `outputters=':
undefined method `clear' for nil:NilClass (NoMethodError)
	from C:/dev/src/scratch/scratch.rb:11


Here is the code:

require 'log4r'
include Log4r
require "rubygems"
require_gem "activerecord"

#require "database/active_storage"

# create a logger named 'mylog' that logs to stdout
mylog = Logger.new 'mylog'
puts mylog.inspect
mylog.outputters = Outputter.stdout

# Now we can log.
def do_log(log)
  log.debug "This is a message with level DEBUG"
  log.info "This is a message with level INFO"
  log.warn "This is a message with level WARN"
  log.error "This is a message with level ERROR"
  log.fatal "This is a message with level FATAL"
end
do_log(mylog)

mylog.level = ERROR
mylog.error  "BLAHBLAH"

Any insight on what's going on here?

phil
94af373d42084bf8b07f461291a910a3?d=identicon&s=25 cap (Guest)
on 2005-12-20 11:35
(Received via mailing list)
I think the activerecord use Ruby's Inner Logger to overwrite the
Log4r's Logger.
you can see my post here

http://groups.google.com/group/comp.lang.ruby/brow...

It would be helpful


phil swenson å??é?ï¼?
This topic is locked and can not be replied to.