标准启动rails日志消息是这样的:
Started GET "/newrelic" for 192.168.18.36 at 2013-09-04 15:19:34 +0200
但我希望有这样的事情:
[request_id] Started GET "/newrelic" for 192.168.18.36 at 2013-09-04 15:19:34 +0200
是否有可能实现这一目标?
答案 0 :(得分:1)
是的,这是可能的。您可以使用config.log_tags来实现此目的。 log_tags选项已添加到Rails 3.2中,可用于在每条日志消息之前添加信息。
在/config/environments/development.rb
中MyApp::Application.configure do
config.log_tags = [:request_id]
...
end