From 04b312a81b5db9b24b1dd80a8becd3f67bb13781 Mon Sep 17 00:00:00 2001 From: InkerBot Date: Wed, 26 Jun 2024 02:26:35 +0800 Subject: [PATCH] remove internal access --- .../logger/impl/log4j2/Log4j2LoggerFactory.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/logger/src/main/java/org/inksnow/cputil/logger/impl/log4j2/Log4j2LoggerFactory.java b/logger/src/main/java/org/inksnow/cputil/logger/impl/log4j2/Log4j2LoggerFactory.java index 8323e92..d2d7604 100644 --- a/logger/src/main/java/org/inksnow/cputil/logger/impl/log4j2/Log4j2LoggerFactory.java +++ b/logger/src/main/java/org/inksnow/cputil/logger/impl/log4j2/Log4j2LoggerFactory.java @@ -3,23 +3,13 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.spi.AbstractLoggerAdapter; import org.apache.logging.log4j.spi.LoggerContext; -import org.apache.logging.log4j.status.StatusLogger; -import org.apache.logging.log4j.util.StackLocatorUtil; -import org.inksnow.cputil.logger.AuroraLogger; import org.slf4j.ILoggerFactory; import org.slf4j.Logger; -import java.util.function.Predicate; - /** * Log4j implementation of SLF4J ILoggerFactory interface. */ public class Log4j2LoggerFactory extends AbstractLoggerAdapter implements ILoggerFactory { - - private static final StatusLogger LOGGER = StatusLogger.getLogger(); - private static final Predicate> CALLER_PREDICATE = clazz -> - !AbstractLoggerAdapter.class.equals(clazz) && !clazz.getName().startsWith(AuroraLogger.SLF4J_PACKAGE_NAME); - @Override protected Logger newLogger(final String name, final LoggerContext context) { final String key = Logger.ROOT_LOGGER_NAME.equals(name) ? LogManager.ROOT_LOGGER_NAME : name; @@ -28,10 +18,6 @@ protected Logger newLogger(final String name, final LoggerContext context) { @Override protected LoggerContext getContext() { - final Class anchor = LogManager.getFactory().isClassLoaderDependent() - ? StackLocatorUtil.getCallerClass(Log4j2LoggerFactory.class, CALLER_PREDICATE) - : null; - LOGGER.trace("Log4jLoggerFactory.getContext() found anchor {}", anchor); - return anchor == null ? LogManager.getContext(false) : getContext(anchor); + return LogManager.getContext(false); } }