0

I have spring boot application A which has MDC logging is added as dependency in project B which also has MDC logging. Both works when they are run independently

Problem is : When I run the project B application, logs of B are displayed. I need the MDC logging parameters of A when A application code is invoke.

Example : MDC config of A application { "TransactionId":"111", "TransactionStatus":"started application A", "application" : "A" }

MDC config of B application { "TransactionId":"222", "TransactionStatus":"started application B", "application" : "B" }

When I run the B applcaiton I see logs as : {"TransactionId":"222","TransactionStatus":"started application B","application":"B"} {"TransactionId":"222","TransactionStatus":"started application B","application":"B"}

I need MDC logs to the displayed when application code A is invoked, which is included as part of gradle dependency in application B.

{"TransactionId":"222","TransactionStatus":"started application B","application":"B"} {"TransactionId":"111","TransactionStatus":"started application A","application":"A"}

Thanks in advance.

  • There is no applciation A when included in B, so how should that work? – M. Deinum Jun 11 '20 at 17:34
  • @M. Deinum - application A is included as jar(added gradle dependency of A in application B) in B. When I invoke rest end point of B, it internally calls application A code. Then, I have to see MDC logs of A like : {"TransactionId":"111","TransactionStatus":"started application A","application":"A", "message" : "message from A"} currenlty I see logs as : {"TransactionId":"222","TransactionStatus":"started application B","application":"B", "message" : "message from B"} {"TransactionId":"222","TransactionStatus":"started application B","application":"B", "message" : "message from A"} – Rajesh Yarraguntla Jun 11 '20 at 18:11
  • Again there is no application A. There is only application B if they both set the same MDC there is only the last one being set. – M. Deinum Jun 11 '20 at 18:13
  • They have different values : Application A - MDC config : { "TransactionId":"111", "TransactionStatus":"started application A", "application" : "A" } Application B - MDC config : { "TransactionId":"222", "TransactionStatus":"started application B", "application" : "B" } Thank you for your quick response. – Rajesh Yarraguntla Jun 11 '20 at 19:25
  • I give up. There is only 1 applciation which happens to use classes from another application. They each write the same fields to the MDC so always the last value will remain. There is no application A or application B. – M. Deinum Jun 12 '20 at 16:21

0 Answers0