Skip to content

Commit

Permalink
Fix empty log file when running via JAR
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangt2333 committed May 29, 2024
1 parent b848c52 commit cfd0fb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/pascal/taie/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public static void main(String... args) {
}
buildWorld(options, plan.analyses());
executePlan(plan);
LoggerConfigs.reconfigure();
}, "Tai-e");
LoggerConfigs.reconfigure();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/pascal/taie/config/LoggerConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ private LoggerConfigs() {
*/
public static void reconfigure() {
// stop the last configuration
Configuration config = ((LoggerContext) LogManager.getContext(false))
.getConfiguration();
LoggerContext ctx = ((org.apache.logging.log4j.core.Logger) logger).getContext();
Configuration config = ctx.getConfiguration();
config.stop();
// re-fetch the configuration and reconfigure it
if (config instanceof Reconfigurable reconfigurableConfig) {
Configurator.reconfigure(reconfigurableConfig.reconfigure());
ctx.reconfigure(reconfigurableConfig.reconfigure());
}
}

/**
* Set the log output file based on the given output dir.
*/
public static void setOutput(File outputDir) {
Configuration config = ((LoggerContext) LogManager.getContext(false))
.getConfiguration();
LoggerContext ctx = ((org.apache.logging.log4j.core.Logger) logger).getContext();
Configuration config = ctx.getConfiguration();
// new a file appender
FileAppender fileAppender = FileAppender
.newBuilder()
Expand Down

0 comments on commit cfd0fb7

Please sign in to comment.