Prior to this commit, if logging.pattern.correlation has been set, then the correlation ID is logged regardless of the flag logging.expect-correlation-id. This is different from what happens with the default correlation patterns.

This commit updates LoggingSystemProperties so that the system property LOG_CORRELATION_PATTERN is set when logging.expect-correlation-id is true. If it is false then the correlation ID won't be logged in any cases.

This also follows gh-38641 from the perspective of logging.

Comment From: wilkinsona

Thanks for the PR. This looks sensible to me but I'd like to double-check with the rest of the team and @jonatan-ivanov.

Comment From: philwebb

Sorry for the delay in reviewing this one. Looking again, I'm not sure that we should make this change. The EXPECT_CORRELATION_ID_PROPERTY is only supposed to change the default value of CORRELATION_PATTERN. If a user specifies their own logging.pattern.correlation property, then it's taken as a signal that they want correlation IDs.

If we change that logic, we could break existing application that want to set correlation IDs even if they aren't using Micrometer tracing.

@danielhcx Was there a specific use-case that caused you to submit this pull-request. If so, perhaps we can find a different way of solving it.

Comment From: philwebb

I'm going to close this one for now. If there's a specific need identified for why we need to make this change we can reopen the issue.