# Conflict between active record and Log4R

**URL:** <https://www.ruby-forum.com/t/conflict-between-active-record-and-log4r/72980>\
**Category:** Ruby\
**Created:** [December 20, 2005, 1:39am UTC](https://www.ruby-forum.com/t/conflict-between-active-record-and-log4r/72980 "2005-12-20T01:39:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![philswenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7feea3/32.png) [@philswenson](https://www.ruby-forum.com/u/philswenson)\
**Post date:** [December 20, 2005, 1:39am UTC](https://www.ruby-forum.com/t/conflict-between-active-record-and-log4r/72980/1 "2005-12-20T01:39:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![philswenson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7feea3/32.png) [@philswenson](https://www.ruby-forum.com/u/philswenson)\
**Post date:** [December 20, 2005, 11:35am UTC](https://www.ruby-forum.com/t/conflict-between-active-record-and-log4r/72980/2 "2005-12-20T11:35:54Z")

</div>

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/browse\_frm/thread/4281944fd2f359cb/27040ba3c4aa7b9a?q=log4r&rnum=4#27040ba3c4aa7b9a](http://groups.google.com/group/comp.lang.ruby/browse_frm/thread/4281944fd2f359cb/27040ba3c4aa7b9a?q=log4r&rnum=4#27040ba3c4aa7b9a)

It would be helpful

phil swenson å??é?ï¼?
