6

Log4j migration guide

https://logging.apache.org/log4j/2.x/manual/migration.html

states that

Calls to org.apache.log4j.Logger.getLogger that accept a LoggerFactory must remove the org.apache.log4j.spi.LoggerFactory and use one of Log4j 2's other extension mechanisms.

What are the extension mechanisms available in log4j2 and how best to migrate a method like below in log4j2

private static TraceLoggerFactory stTraceFactory = new TraceLoggerFactory();

public static Logger getTraceLogger(final String name) {
    return getLogger(name, stTraceFactory);
}


class TraceLoggerFactory implements LoggerFactory {
    @Override
    public Logger makeNewLoggerInstance(final String name) {
        return new TraceLogger(name);
    }
}
Arvind
  • 61
  • 1
  • 3

0 Answers0