Skip to content

Commit

Permalink
Handle logging shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Feb 10, 2025
1 parent fc1e6d6 commit 7764be4
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.PrintWriter;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import org.apache.logging.log4j.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -100,8 +101,12 @@ private synchronized void maybeExitJVM() {
} catch (InterruptedException e) {
// ignore
}
// shutdown log4j2 logging to prevent log truncation
LogManager.shutdown();
// flush log buffers
System.err.flush();
System.out.flush();
// exit JVM immediately
Runtime.getRuntime().halt(1);
}).start();
exitThreadStarted = true;
Expand Down

0 comments on commit 7764be4

Please sign in to comment.