Rails Custom UUID Tagger in Logs

Sometimes there rises a need that the UUID in the rails logs should be a specific format.

When our project was on Rails 3.2, the UUID was something like this ‘085dfb20fbaf4172afd5dd56c76f8cc9‘. We were using this format to parse our logs for additional information.

When we upgraded to Rails 4, all our parsing logic broke. This is when we discovered that Rails 4 generated UUID is this format ‘1ca71cd6-08c4-4855-9381-2f41aeffe59c’.

I dug deeper into the config and found this in the application.rb config file.

To get back our original format, I had to tweak it to

And Voila! Problem solved.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">