有没有一种方法可以在启动应用程序时通过传递命令行属性来覆盖Java中的LogManager配置。
目前,我使用以下方式将这些属性传递给LogManager:
File fn = new File(filename);
URL url = fn.toURI().toURL();
LogManager.getLogManager().readConfiguration(url.openStream())
filename contains this
handlers = java.util.logging.ConsoleHandler
.level = CONFIG
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = abc.common.util.LogFormatter
java.util.logging.FileHandler.level = ALL
java.util.logging.FileHandler.formatter = abc.common.util.LogFormatter
我无法更改文件,但需要将.level = CONFIG更改为其他值。我无法更改代码,但只能在启动应用程序时传递Java属性。
是否有可能实现?