Tagged loggers like ActiveSupport::TaggedLogger make logging both named and unnamed tags visible for better application debugging. Currently log_tags only supported an array of tags such as:
config.log_tags = [ :remote_ip, ->(request) { some_computed_value } ]
However as this list gets long it has two issues:
- Parsing JSON logs requires positional references (ie remote_ip will always be at some index)
- Some tags look similar and are hard to discern in a log message. For example a datadog trace id and epoch time look indistinguishable to a human reading those logs
I submitted Allow log_tags to take a hash for a tagged logger by allcentury · Pull Request #38009 · rails/rails · GitHub as one solution