在我已经记录了一些行之后,有没有办法重新配置 tinylog2 属性?我想在运行期间更改日志文件名,当用户更改选择(使用不同的文件)时,无需重新启动我的程序。
我的代码只在第一次工作:
private void initLogger(String fileName) {
// log to file
Configuration.set("writer","file");
// set log file name
if (inFileCheckBox.isSelected()){ // log file name is working file name
Configuration.set("writer.file",fileName);
}else{ // log file name by month (MM-YYYY)
Configuration.set("writer.file", new SimpleDateFormat("MM-yyyy").format(new Date()));
}
Logger.info("yow it's : {}", fileName);
}
在更改参数之前,我尝试手动关闭它,但没有帮助:
ProviderRegistry.getLoggingProvider().shutdown();
这是我第二次运行该方法时遇到的错误:
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Configuration cannot be changed after applying to tinylog
谢谢!