diff --git a/sofa-ark-parent/core/common/src/main/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelector.java b/sofa-ark-parent/core/common/src/main/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelector.java index 60f8ee140..8da933a4c 100644 --- a/sofa-ark-parent/core/common/src/main/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelector.java +++ b/sofa-ark-parent/core/common/src/main/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelector.java @@ -16,11 +16,8 @@ */ package com.alipay.sofa.ark.common.adapter; -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.selector.ContextSelector; -import ch.qos.logback.classic.spi.LoggerContextListener; import com.alipay.sofa.ark.common.util.StringUtils; import java.util.HashMap; @@ -86,7 +83,6 @@ private LoggerContext getContext(ClassLoader cls) { if (null == loggerContext) { loggerContext = new LoggerContext(); loggerContext.setName(Integer.toHexString(System.identityHashCode(cls))); - loggerContext.addListener(new ArkLoggerContextListener(this)); CLASS_LOADER_LOGGER_CONTEXT.put(cls, loggerContext); } } @@ -138,38 +134,4 @@ public LoggerContext removeContext(ClassLoader cls) { public List getContextNames() { return CLASS_LOADER_LOGGER_CONTEXT.values().stream().map(LoggerContext::getName).collect(Collectors.toList()); } - - public static class ArkLoggerContextListener implements LoggerContextListener { - - private ArkLogbackContextSelector contextSelector; - - public ArkLoggerContextListener(ArkLogbackContextSelector contextSelector) { - this.contextSelector = contextSelector; - } - - @Override - public boolean isResetResistant() { - return true; - } - - @Override - public void onStart(LoggerContext context) { - - } - - @Override - public void onReset(LoggerContext context) { - - } - - @Override - public void onStop(LoggerContext context) { - contextSelector.detachLoggerContext(context.getName()); - } - - @Override - public void onLevelChange(Logger logger, Level level) { - - } - } } diff --git a/sofa-ark-parent/core/common/src/test/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelectorTest.java b/sofa-ark-parent/core/common/src/test/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelectorTest.java index 0e231751c..4cfb2e185 100644 --- a/sofa-ark-parent/core/common/src/test/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelectorTest.java +++ b/sofa-ark-parent/core/common/src/test/java/com/alipay/sofa/ark/common/adapter/ArkLogbackContextSelectorTest.java @@ -64,8 +64,6 @@ public void testContextSelector() throws NoSuchMethodException, InvocationTarget Assert.assertNotNull(invoke); Assert.assertEquals(invoke, contextSelector.getLoggerContext(contextName)); Assert.assertTrue(contextSelector.getContextNames().contains(contextName)); - contextSelector.getLoggerContext(contextName).stop(); - Assert.assertTrue(contextSelector.getContextNames().isEmpty()); } }