File tree 1 file changed +9
-4
lines changed
src/main/java/com/cloudbees/jenkins/support
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -862,6 +862,15 @@ public Void call() {
862
862
// avoid double installation of the handler. JNLP agents can reconnect to the controller multiple times
863
863
// and each connection gets a different RemoteClassLoader, so we need to evict them by class name,
864
864
// not by their identity.
865
+ closeAll ();
866
+ Runtime .getRuntime ().addShutdownHook (new Thread (LogInitializer ::closeAll , "close log handlers" ));
867
+ LogHolder .AGENT_LOG_HANDLER .setLevel (level );
868
+ LogHolder .AGENT_LOG_HANDLER .setDirectory (new File (rootPath .getRemote (), SUPPORT_DIRECTORY_NAME ), "all" );
869
+ ROOT_LOGGER .addHandler (LogHolder .AGENT_LOG_HANDLER );
870
+ return null ;
871
+ }
872
+
873
+ private static void closeAll () {
865
874
for (Handler h : ROOT_LOGGER .getHandlers ()) {
866
875
if (h .getClass ()
867
876
.getName ()
@@ -874,10 +883,6 @@ public Void call() {
874
883
}
875
884
}
876
885
}
877
- LogHolder .AGENT_LOG_HANDLER .setLevel (level );
878
- LogHolder .AGENT_LOG_HANDLER .setDirectory (new File (rootPath .getRemote (), SUPPORT_DIRECTORY_NAME ), "all" );
879
- ROOT_LOGGER .addHandler (LogHolder .AGENT_LOG_HANDLER );
880
- return null ;
881
886
}
882
887
}
883
888
You can’t perform that action at this time.
0 commit comments