Sławosz
Sławosz

Reputation: 11687

Is this possible to change rails logs messages?

Standard start of rails log message is like this:

Started GET "/newrelic" for 192.168.18.36 at 2013-09-04 15:19:34 +0200

But I would like to have something like this:

[request_id] Started GET "/newrelic" for 192.168.18.36 at 2013-09-04 15:19:34 +0200

Is it possible to achevie this?

Upvotes: 0

Views: 149

Answers (1)

Chawarong Songserm PMP
Chawarong Songserm PMP

Reputation: 1774

Yes, it's possible. You can achieve this by using config.log_tags. The log_tags option was added in Rails 3.2 and can be used to prepend information to each log message.

In /config/environments/development.rb

MyApp::Application.configure do
  config.log_tags = [:request_id]
  ...
end

Upvotes: 1

Related Questions