Skip to content

Commit

Permalink
fix:fix log4j2 not working bug. (#181)
Browse files Browse the repository at this point in the history
* fix:fix log4j2 not working bug.

* fix:fix log4j2 not working bug.
  • Loading branch information
SkyeBeFreeman authored Jul 22, 2022
1 parent d2ecce6 commit 41454a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -59,7 +61,7 @@ public void loadConfiguration() {
}
Map<String, LoggerConfig> 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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
additivity="false">
<AppenderRef ref="POLARIS_LOG_FILE"/>
</Logger>
<Logger name="polaris-update-event"
<Logger name="polaris-update-event-async"
level="${sys:polaris-update-event.log.level:-info}"
additivity="false">
<AppenderRef ref="POLARIS_UPDATE_EVENT_LOG_FILE"/>
</Logger>
<AsyncLogger name="polaris-update-event-async"
level="${sys:polaris-update-event.log.level:-info}"
additivity="false">
<AppenderRef ref="POLARIS_UPDATE_EVENT_LOG_FILE"/>
</AsyncLogger>
<!-- <AsyncLogger name="polaris-update-event-async"-->
<!-- level="${sys:polaris-update-event.log.level:-info}"-->
<!-- additivity="false">-->
<!-- <AppenderRef ref="POLARIS_UPDATE_EVENT_LOG_FILE"/>-->
<!-- </AsyncLogger>-->
</Loggers>
</Configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 41454a8

Please sign in to comment.