Skip to content

Logging user_id on log_tags #152

Answered by truongnmt
truongnmt asked this question in Q&A
Discussion options

You must be logged in to vote

Ah thanks! By implementing append_info_to_payload we could add custom data to its payload from any controller. Rails support this:
https://apidock.com/rails/v6.0.0/ActionController/Instrumentation/append_info_to_payload

Also written in our doc:

Adding custom data to the Rails Completed log message:
https://rocketjob.github.io/semantic_logger/rails.html

Just make sure to implement this method in the base controller of all requests. That's very close and enough to my original purposes. Adding to log_tags seems a bit difficult, I should read the docs more carefully. Thanks very much!!!

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by reidmorrison
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #103 on January 17, 2022 20:24.