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
> -----Original Message-----
> From: rails-bounces@lists.rubyonrails.org
> [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Fino Fontana
> Sent: Friday, May 19, 2006 1:51 AM
> To: rails@lists.rubyonrails.org
> Subject: [Rails] Re: log4r and rails
>
> Mark Bates wrote:
> > me too!! sorry, i don''t have the answer to this question, but
today
> > i''ve been trying to figure out how to use for a
client''s
> project, and
> > i can''t figure it out either! i thought i was the idiot!
> >
> > i''m also using 1.0.5 of log4r, as well as rails 1.1.2, and
lighttpd
> > 1.4.11.
> >
> > does anyone out there know how to configure log4r with rails??
> >
> > thanks peeps.
> > -mark
> >
> > Helium Exchange wrote:
> >> Hey there folks. I would really like to use log4r as my default
> >> logger in Rails, but I''m having a hard time getting it to
> work. I''m
> >> not even sure I''m plugging it in in the right place.
I''m
> using log4r
> >> 1.0.5 and rails 1.1.1.
> >>
> >> I would love it if someone could either point me to a good
> tutorial
> >> on how to use log4r with rails, or at least point me in the right
> >> direction as far as how to configure/set it up.
> >>
> >> Thanks a lot!
>
> Any progress on this subject? Also an example of a simple xml
> configuration would be welcome. The log4r manual and xml
> example a rather poor (with due respect to the maker of log4r
> himself, as I think log4r is very promising)
>
> Thanks,
> Fino
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>