Java, Programming, Multithreading, Software Development, Software Engineering.
public class MyService { private static final Logger logger = LoggerFactory.getLogger(MyService.class); private static final ThreadLocal<String> requestId = new ThreadLocal<>(); public void processRequest() { // Set request ID in the MDC context requestId.set(generateRequestId());