RE: Re: log4r and rails

The first question I would ask (partially out of curiosity) is what
log4r specific feature are you trying to use?

While there are some neat log4r features, the built in logger provides
(from my perspective) a good logging framework already probably
addresses most logging needs.

http://wiki.rubyonrails.com/rails/pages/HowtoConfigureLogging

That said, a basic setup to use log4r in rails follows a very similar
approach to using the built in logger.

Install the log4r gem

gem install log4r

Then edit your environment.rb file to use the gem and setup the logger

require “rubygems”
require “log4r”

#Setup Log4r Logging
L4R = Log4r::Logger.new(“RailsLogging”)
Log4r::FileOutputter.new(‘logfile’,
:filename=>“#{RAILS_ROOT}/log/log4r.log”,
:trunc=>false,
:level=>Log4r::DEBUG)
L4R.add(‘logfile’)

Once you have the logger defined you can then make logging calls from
within your model, controllers and views

Model / Controller

L4R.debug “Debug message from Model or controller”

View

<% L4R.debug “Test debug from a view” %>

Hope this helps get you started.

–Bill