Skip to content

Commit 41454a8

Browse files
fix:fix log4j2 not working bug. (#181)
* fix:fix log4j2 not working bug. * fix:fix log4j2 not working bug.
1 parent d2ecce6 commit 41454a8

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

polaris-common/polaris-logging/src/main/java/com/tencent/polaris/logging/log4j2/Log4j2PolarisLogging.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import org.apache.logging.log4j.core.config.ConfigurationSource;
3131
import org.apache.logging.log4j.core.config.LoggerConfig;
3232

33+
import static com.tencent.polaris.logging.LoggingConsts.LOGGING_UPDATE_EVENT;
34+
3335
public class Log4j2PolarisLogging extends AbstractPolarisLogging {
3436

3537
private static final String LOG4J2_LOCATION = "classpath:polaris-log4j2.xml";
@@ -59,7 +61,7 @@ public void loadConfiguration() {
5961
}
6062
Map<String, LoggerConfig> loggers = configuration.getLoggers();
6163
for (String name : loggers.keySet()) {
62-
if (name.startsWith(LOGGER_PREFIX)) {
64+
if (name.startsWith(LOGGER_PREFIX) || name.contains(LOGGING_UPDATE_EVENT)) {
6365
contextConfiguration.addLogger(name, loggers.get(name));
6466
}
6567
}

polaris-common/polaris-logging/src/main/resources/polaris-log4j2.xml

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
additivity="false">
3939
<AppenderRef ref="POLARIS_LOG_FILE"/>
4040
</Logger>
41-
<Logger name="polaris-update-event"
41+
<Logger name="polaris-update-event-async"
4242
level="${sys:polaris-update-event.log.level:-info}"
4343
additivity="false">
4444
<AppenderRef ref="POLARIS_UPDATE_EVENT_LOG_FILE"/>
4545
</Logger>
46-
<AsyncLogger name="polaris-update-event-async"
47-
level="${sys:polaris-update-event.log.level:-info}"
48-
additivity="false">
49-
<AppenderRef ref="POLARIS_UPDATE_EVENT_LOG_FILE"/>
50-
</AsyncLogger>
46+
<!-- <AsyncLogger name="polaris-update-event-async"-->
47+
<!-- level="${sys:polaris-update-event.log.level:-info}"-->
48+
<!-- additivity="false">-->
49+
<!-- <AppenderRef ref="POLARIS_UPDATE_EVENT_LOG_FILE"/>-->
50+
<!-- </AsyncLogger>-->
5151
</Loggers>
5252
</Configuration>

polaris-discovery/polaris-discovery-factory/src/test/java/com/tencent/polaris/discovery/test/core/ConsumerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void testGetNotExistsService() {
189189
GetOneInstanceRequest request = new GetOneInstanceRequest();
190190
request.setNamespace(NAMESPACE_TEST);
191191
request.setService(NOT_EXISTS_SERVICE);
192-
Thread.sleep(3000);
192+
Thread.sleep(13000);
193193
InstancesResponse oneInstance = consumerAPI.getOneInstance(request);
194194
Assert.assertEquals(1, oneInstance.getInstances().length);
195195
} catch (InterruptedException e) {

0 commit comments

Comments
 (0)