Browse Source

REPORT-135672 fix: 启动阶段从本地获取日志级别配置,兼容fp的修改

fbp/release
Anner 2 months ago
parent
commit
0e7d26b971
  1. 32
      designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java

32
designer-realize/src/main/java/com/fanruan/boot/env/DesignEnvComponent.java vendored

@ -55,6 +55,7 @@ import com.fr.env.detect.EnvDetectorCenter;
import com.fr.event.EventDispatcher;
import com.fr.general.FRLogger;
import com.fr.general.log.Log4jConfig;
import com.fr.general.log.Log4jConfigFactory;
import com.fr.general.log.Log4jUtils;
import com.fr.intelli.metrics.Compute;
import com.fr.intelli.metrics.DBMonitorInterceptor;
@ -88,6 +89,7 @@ import com.fr.stable.db.session.DBSession;
import com.fr.stable.project.ProjectConstants;
import com.fr.tenant.context.TenantContext;
import com.fr.tenant.context.provider.CurrentTenantKey;
import com.fr.third.apache.logging.log4j.Level;
import com.fr.third.apache.logging.log4j.core.config.Configurator;
import com.fr.third.net.bytebuddy.implementation.MethodDelegation;
import com.fr.third.net.bytebuddy.matcher.ElementMatchers;
@ -244,6 +246,8 @@ public class DesignEnvComponent {
* ----------- logger --------
*/
private void startLogger() {
// 获取本地的日志级别配置
Log4jConfigFactory.getInstance().setRootLevel(Log4jConfig.getInstance().getRootLevel());
URI uri = Log4jUtils.buildUserConfigURI(StringUtils.EMPTY);
FRLogger.getLogger().config(uri);
// 日志配置更新的监听在FRLogger里面,fbp去掉了但是设计器本地还是需要这个监听的,初始化的时候监听一下
@ -251,21 +255,19 @@ public class DesignEnvComponent {
}
private void listenConfig() {
/// 等fbp改完,现在先配合打包注释掉
// ValidateConfigManger.getInstance().registerListener(new ConfigChangeListener() {
//
// @Override
// public boolean accept(Class<? extends Configuration> configClass) {
// return configClass.equals(Log4jConfig.class);
// }
//
// @Override
// public void change() {
// // The root logger is the topmost logger with a name of "" (the empty string).
// Configurator.setAllLevels("", Log4jConfig.getInstance().getRootLevel());
// }
// });
ValidateConfigManger.getInstance().registerListener(new ConfigChangeListener() {
@Override
public boolean accept(Class<? extends Configuration> configClass) {
return configClass.equals(Log4jConfig.class);
}
@Override
public void change() {
// The root logger is the topmost logger with a name of "" (the empty string).
Configurator.setAllLevels("", Log4jConfig.getInstance().getRootLevel());
}
});
}
private void stopLogger() {

Loading…
Cancel
Save