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

Community
  • 1
  • 1
John Hinnegan
  • 5,864
  • 2
  • 48
  • 64

1 Answers1

2

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.

Michelle Tilley
  • 157,729
  • 40
  • 374
  • 311