日志bug,临时测试

This commit is contained in:
2026-07-20 18:33:02 +08:00
parent ae6d5453e6
commit dd7b691993

View File

@@ -67,10 +67,11 @@ public class NacosLogbackConfigLoader implements SpringApplicationRunListener, A
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory(); LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator(); JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context); configurator.setContext(context);
context.reset();
// 注意:变量名必须与 XML 中 ${...} 内的名称完全一致 // 注意:变量名必须与 XML 中 ${...} 内的名称完全一致
context.putProperty("log.projectName", projectName != null ? projectName : "undefined_pqs"); context.putProperty("log.projectName", projectName != null ? projectName : "undefined_pqs");
context.putProperty("log.commonLevel", logLevel != null ? logLevel : "INFO"); context.putProperty("log.commonLevel", logLevel != null ? logLevel : "INFO");
context.reset();
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(logbackConfigContent.getBytes(StandardCharsets.UTF_8))) { try (ByteArrayInputStream inputStream = new ByteArrayInputStream(logbackConfigContent.getBytes(StandardCharsets.UTF_8))) {
configurator.doConfigure(inputStream); configurator.doConfigure(inputStream);
Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);