2020-06-20 20:58:05.855 INFO --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 5678 BEGIN 2020-06-20 20:58:05.855 INFO --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 5678 BEGIN COMPLETE ORDER ORDER 2020-06-20 20:58:05.856 INFO --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 5678 Check user userId : a8caf905-4116-44cf-9fc7-572b96b11e96 2020-06-20 20:58:07.850 INFO --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 1234 BEGIN 2020-06-20 20:58:07.850 INFO --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 1234 BEGIN COMPLETE ORDER ORDER 2020-06-20 20:58:07.850 INFO --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 1234 Check user userId : c75043d4-064a-4c41-8b5d-549ceee72914 2020-06-20 20:58:09.247 INFO --- blog.surapong.example.logproblem.service.UserService : Check user userId : c75043d4-064a-4c41-8b5d-549ceee72914 BEGIN 2020-06-20 20:58:09.247 INFO --- blog.surapong.example.logproblem.service.UserService : Check user userId : c75043d4-064a-4c41-8b5d-549ceee72914 FINISH 2020-06-20 20:58:09.247 INFO --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 1234 END COMPLETE ORDER 2020-06-20 20:58:09.247 INFO --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 1234 END 2020-06-20 20:58:13.026 INFO --- blog.surapong.example.logproblem.service.UserService : Check user userId : a8caf905-4116-44cf-9fc7-572b96b11e96 BEGIN 2020-06-20 20:58:13.026 INFO --- blog.surapong.example.logproblem.service.UserService : Check user userId : a8caf905-4116-44cf-9fc7-572b96b11e96 FINISH 2020-06-20 20:58:13.026 INFO --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 5678 END COMPLETE ORDER 2020-06-20 20:58:13.026 INFO --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 5678 END
2020-06-20 21:36:53.976 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 1234 BEGIN 2020-06-20 21:36:53.976 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 1234BEGIN COMPLETE ORDER ORDER 2020-06-20 21:36:53.976 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 1234Check user userId : 27dc9962-20c8-4f1a-80fa-fe5235baa43f 2020-06-20 21:36:55.262 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 5678 BEGIN 2020-06-20 21:36:55.262 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 5678 BEGIN COMPLETE ORDER ORDER 2020-06-20 21:36:55.262 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 5678 Check user userId : 7d6ca7e1-4dfa-4aee-9f75-93eb451fbeab 2020-06-20 21:36:59.203 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.service.UserService : Check user userId : 27dc9962-20c8-4f1a-80fa-fe5235baa43f BEGIN 2020-06-20 21:36:59.203 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.service.UserService : Check user userId : 27dc9962-20c8-4f1a-80fa-fe5235baa43f FINISH 2020-06-20 21:36:59.203 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 1234 END COMPLETE ORDER 2020-06-20 21:36:59.203 INFO 004E4E7AE9FE47E9BBAAAA5A078608F2 --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 1234 END 2020-06-20 21:37:01.167 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.service.UserService : Check user userId : 7d6ca7e1-4dfa-4aee-9f75-93eb451fbeab BEGIN 2020-06-20 21:37:01.167 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.service.UserService : Check user userId : 7d6ca7e1-4dfa-4aee-9f75-93eb451fbeab FINISH 2020-06-20 21:37:01.167 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.service.OrderService : Complete order orderId : 5678END COMPLETE ORDER 2020-06-20 21:37:01.167 INFO 6E81515230B941ECAEE47438BE2C9370 --- blog.surapong.example.logproblem.api.controller.TestController : TEST_LOG orderId : 5678 END
จะเห็นว่าหลัง INFO จะมีเลขยาวๆโผล่ขึ้นมา ซึ่งเลขนี้เป็นเลข ID ของแต่ละ Request นั่นเองคราวนี้เราสามารถ Grep log ด้วยเลข ID นี้ ทำให้ได้ Log ที่เกี่ยวข้องกับ Request นี้ทั้งหมด