conflict between active record and Log4R

P

phil swenson

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
 

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