Include params/request information in Rails logger?

Posted by Dan Hill on Stack Overflow See other posts from Stack Overflow or by Dan Hill
Published on 2010-04-19T13:15:56Z Indexed on 2010/04/19 13:53 UTC
Read the original article Hit count: 483

Filed under:
|
|
|
|

Hi everyone,

I'm trying to get some more information into my Rails logs, specifically the requested URI or current params, if available (and I appreciate that they won't always be). However I just don't seem able to. Here's what I've done so far:

#config/environments/production.rb
config.logger = Logger.new(config.log_path)
config.log_level = :error
config.logger.level = Logger::ERROR

#config/environment.rb
class Logger
  def format_message(level, time, progname, msg)
    "**********************************************************************\n#{level} #{time.to_s(:db)} -- #{msg}\n"
  end  
end

So I can customize the message fine, yet I don't seem to be able to access the params/request variables here. Does anyone know if this is possible, and if so how? Or if there's a better way to get this information? (Perhaps even something Redis based?)

Thanks loads,

Dan

© Stack Overflow or respective owner

Related posts about rails

Related posts about ruby