I am working in j2ee application. we are using session bean (20 instance). in that MDC used to log the message id for each request.
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
public class ReqEng{
void process(){
Logger logger = Logger.getLogger(this.getClass().getPackage().getName());
MDC.put("MESSAGE_ID", messageID);
logger.info(" Hit ReqEng... !!! ");
MDC.remove("MESSAGE_ID"); }
}
Here my question is, When this beans are running with multiple instance. one instance's info will get collide with other instance's log info?
The MDC is thread-local so calls within different threads (whether on the same instance or different instances of the bean) will not collide.