java当在spring应用程序上下文之外使用时,我可以禁用YamlPropertiesFactoryBean的日志记录吗?
我正在使用YamlPropertiesFactoryBean加载yml配置文件,并将繁重的绑定工作委托给spring。这是在现有的非spring应用程序上完成的。这很好用,但是有一些默认的控制台日志记录,我很难禁用
是否可以在任何spring应用程序上下文之外以编程方式禁用此默认控制台日志记录
我使用的是spring boot starter 2.4.2
MyConfig loadConfigFromYaml(String ymlFilePath) {
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new FileSystemResource(ymlFile));
Properties properties = yaml.getObject();
ConfigurationPropertySource props = new MapConfigurationPropertySource(properties);
Binder binder = new Binder(props);
MyConfig config = binder.bind("foo", MyConfig.class).get();
return MyConfig;
}
执行getObject时,我的控制台输出将填充以下内容:
22:13:37.201 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loading from YAML: file [...]
22:13:37.223 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Merging document (no matchers set): ...
22:13:37.224 [main] DEBUG org.springframework.beans.factory.config.YamlPropertiesFactoryBean - Loaded 1 document from YAML resource: file [...]
共 (0) 个答案