Rails 3.2.2 log files unordered, requests intertwined

后端 未结 6 1018
礼貌的吻别
礼貌的吻别 2021-02-08 02:02

I recollect getting log files that were nicely ordered, so that you could follow one request, then the next, and so on.

Now, the log files are, as my 4 year old says \"a

6条回答
  •  名媛妹妹
    2021-02-08 02:40

    Yep!, they have made some changes in the ActiveSupport::BufferedLogger so it is not any more waiting until the request has ended to flush the logs:

    • http://news.ycombinator.com/item?id=4483390
    • https://github.com/rails/rails/commit/04ef93dae6d9cec616973c1110a33894ad4ba6ed

    But they have added the ActiveSupport::TaggedLogging which is very funny and you can stamp every log with any kind of mark you want.

    In your case could be good to stamp the logs with the request UUID like this:

    # config/application.rb
    config.log_tags = [:uuid]
    

    Then even if the logs are messed up you still can follow which of them correspond to the request you are following up.

    You can make more funny things with this feature to help you in your logs study:

    • How to log user_name in Rails?
    • http://zogovic.com/post/21138929607/running-time-in-rails-logs

提交回复
热议问题