-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Currently log4j2-android uses the log4j2.loggerContextFactory to register itself with the Log4j API. The usage of this property is deprecated since version 2.24.0 and will be removed in the future.
Please implement a Provider class and register it with ServiceLoader in a META-INF/services/org.apache.logging.log4j.spi.Provider class.
The Provider service determines both the LoggerContextFactory to use with the LogManager class and the ThreadContextMap to use with the ThreadContext class. Since the Android Log API does not handle context data, I would suggest to set the latter to NoOpThreadContextMap:
public class AndroidProvider extends Provider {
private static final LoggerContextFactory CONTEXT_FACTORY = new AndroidLoggerContextFactory();
public AndroidProvider() {
// Since this provider is targeted at Android,
// use a priority higher than those of the Log4j API implementations targeted at the JRE.
super(25, CURRENT_VERSION);
}
@Override
public LoggerContextFactory getLoggerContextFactory() {
return CONTEXT_FACTORY;
}
@Override
public ThreadContextMap getThreadContextMapInstance() {
// Android does not provide an MDC implementation
return NoOpThreadContextMap.INSTANCE;
}
}Metadata
Metadata
Assignees
Labels
No labels