I would like to define a custom logger for my Rails 3 app, in a way that it does not replace the original logger (I still make use of its information).
I assumed that I could define in a lib a class that inherited BufferedLogger as I've seen on some blogs. Then I would instantiate a variable to represent my logger, on the end of my application.rb with those lines:
require 'smart_logger.rb'
sl = SmartLogger.new("log/soccer.log")
And in my controller (as models and views) I would be able to use:
sl.warn("Tentativa #{session[:login_number]} de fazer login do IP#{request.remote_ip}, email:#{@user_session.try :email}, senha: #{@user_ses开发者_开发百科sion.try :password}. ")
My question is how can I achieve to have my custom logger available application wide and flushing properly? That would be sort of a parallel logger.
Better describing, its more like an User-Action-Logger, targeting Data Minning.
btw: I guess it has a great performance :)
http://fabianosoriani.wordpress.com/2010/11/01/rails-user-action-logger
Here is a gem that makes log output customization really easy in Rails3: https://github.com/johmas/itslog
精彩评论