Logging username in log4j
问题 I need to print username and client IP address in logs.but username is only prints for first thread using MDC in log4j.From next thread the values are printed as empty. can any one suggest how to proceed further on this . 回答1: MDC uses ThreadLocal to store values. Maybe Log4J (like Logback) uses InheritableThreadLocal which partially solves problems like yours: newly created thread inherits MDC from parent thread. I guess you are using some sort of pooling (we are rarely creating dedicated