开发者

Better way to format log messages in Rails 3?

I found this. It seems kind of ugly to just throw this into environment.rb. The question is kind of old. I just wanted to ask if there was a better way to do this now.

The problem (if you don't want to click through), is including your custom log message formatter. (The problem I'm solving is that I want to assign a guid to every request, prepend all log messages from开发者_运维百科 that request with the guid, and then return the guid in meta data to the client a.k.a. request id)

Rails logger format string configuration


You can put it in an initializer.

Initializers can be any name and go in config/initializers. Every file in this directory is loaded at startup; it's a great place to put miscellaneous startup code that doesn't seem to fit anywhere else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜