From 41454a8e8e7b13d8d593f745ef2cd90c1867b965 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Fri, 22 Jul 2022 14:30:54 +0800 Subject: [PATCH] fix:fix log4j2 not working bug. (#181) * fix:fix log4j2 not working bug. * fix:fix log4j2 not working bug. --- .../polaris/logging/log4j2/Log4j2PolarisLogging.java | 4 +++- .../src/main/resources/polaris-log4j2.xml | 12 ++++++------ .../polaris/discovery/test/core/ConsumerTest.java | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/polaris-common/polaris-logging/src/main/java/com/tencent/polaris/logging/log4j2/Log4j2PolarisLogging.java b/polaris-common/polaris-logging/src/main/java/com/tencent/polaris/logging/log4j2/Log4j2PolarisLogging.java index eef8e8e52..779f47e76 100644 --- a/polaris-common/polaris-logging/src/main/java/com/tencent/polaris/logging/log4j2/Log4j2PolarisLogging.java +++ b/polaris-common/polaris-logging/src/main/java/com/tencent/polaris/logging/log4j2/Log4j2PolarisLogging.java @@ -30,6 +30,8 @@ import org.apache.logging.log4j.core.config.ConfigurationSource; import org.apache.logging.log4j.core.config.LoggerConfig; +import static com.tencent.polaris.logging.LoggingConsts.LOGGING_UPDATE_EVENT; + public class Log4j2PolarisLogging extends AbstractPolarisLogging { private static final String LOG4J2_LOCATION = "classpath:polaris-log4j2.xml"; @@ -59,7 +61,7 @@ public void loadConfiguration() { } Map loggers = configuration.getLoggers(); for (String name : loggers.keySet()) { - if (name.startsWith(LOGGER_PREFIX)) { + if (name.startsWith(LOGGER_PREFIX) || name.contains(LOGGING_UPDATE_EVENT)) { contextConfiguration.addLogger(name, loggers.get(name)); } } diff --git a/polaris-common/polaris-logging/src/main/resources/polaris-log4j2.xml b/polaris-common/polaris-logging/src/main/resources/polaris-log4j2.xml index 09a9fa8fb..cb5397baf 100644 --- a/polaris-common/polaris-logging/src/main/resources/polaris-log4j2.xml +++ b/polaris-common/polaris-logging/src/main/resources/polaris-log4j2.xml @@ -38,15 +38,15 @@ additivity="false"> - - - - + + + + + diff --git a/polaris-discovery/polaris-discovery-factory/src/test/java/com/tencent/polaris/discovery/test/core/ConsumerTest.java b/polaris-discovery/polaris-discovery-factory/src/test/java/com/tencent/polaris/discovery/test/core/ConsumerTest.java index c038e876c..b05f87899 100644 --- a/polaris-discovery/polaris-discovery-factory/src/test/java/com/tencent/polaris/discovery/test/core/ConsumerTest.java +++ b/polaris-discovery/polaris-discovery-factory/src/test/java/com/tencent/polaris/discovery/test/core/ConsumerTest.java @@ -189,7 +189,7 @@ public void testGetNotExistsService() { GetOneInstanceRequest request = new GetOneInstanceRequest(); request.setNamespace(NAMESPACE_TEST); request.setService(NOT_EXISTS_SERVICE); - Thread.sleep(3000); + Thread.sleep(13000); InstancesResponse oneInstance = consumerAPI.getOneInstance(request); Assert.assertEquals(1, oneInstance.getInstances().length); } catch (InterruptedException e) {