i know that one solution would be to set the logger object as static so it wont be instanciated every time but is there any standard solution for this kind of problem.
This is what I do in my application. It works great.
Many of my classes have this as the first line:
public class SomeClass {
private static final Logger LOG = LoggerFactory.getLogger(SomeClass.class);
// the rest of the class
}
One of the design goals of logback is to audit and debug complex distributed applications. Most real-world distributed systems need to deal with multiple clients simultaneously. In a typical multithreaded implementation of such a system, different threads will handle different clients. A possible but slightly discouraged approach to differentiate the logging output of one client from another consists of instantiating a new and separate logger for each client. This technique promotes the proliferation of loggers and may increase their management overhead.
Read the entire link, it does a better job of explaining MDC than I ever could.