This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.14.x by this push:
     new 8ef8a592a3b3 CAMEL-23111: camel-jbang - camel run will log all fatal 
errors using LOG so they can be captured by configured logging settings, which 
may be sending logs to monitoring systems. Although camel run is only/primary 
for development purpose. (#21671)
8ef8a592a3b3 is described below

commit 8ef8a592a3b3265fa219309a5cfc4128031b8163
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Mar 2 11:38:03 2026 +0100

    CAMEL-23111: camel-jbang - camel run will log all fatal errors using LOG so 
they can be captured by configured logging settings, which may be sending logs 
to monitoring systems. Although camel run is only/primary for development 
purpose. (#21671)
---
 .../org/apache/camel/dsl/jbang/core/commands/Run.java     | 15 ++++++++-------
 .../src/main/java/org/apache/camel/main/KameletMain.java  |  7 +++++++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index 6687b5d4dd1a..6502d193ebca 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -1652,14 +1652,15 @@ public class Run extends CamelCommand {
     }
 
     protected int runKameletMain(KameletMain main) throws Exception {
-        main.start();
-        main.run();
-
-        // cleanup and delete log file
-        if (logFile != null) {
-            FileUtil.deleteFile(logFile);
+        try {
+            main.start();
+            main.run();
+        } finally {
+            // cleanup and delete log file
+            if (logFile != null) {
+                FileUtil.deleteFile(logFile);
+            }
         }
-
         return main.getExitCode();
     }
 
diff --git 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
index fc9b5953dc70..072f8b2e5054 100644
--- 
a/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
+++ 
b/dsl/camel-kamelet-main/src/main/java/org/apache/camel/main/KameletMain.java
@@ -172,6 +172,13 @@ public class KameletMain extends MainCommandLineSupport {
         // normal exit
     }
 
+    @Override
+    protected void doFail(Exception e) {
+        // ensure any unhandled fatal errors are also logged before 
terminating process
+        LOG.error("Error starting Camel: {}", e, e);
+        super.doFail(e);
+    }
+
     /**
      * Binds the given <code>name</code> to the <code>bean</code> object, so 
that it can be looked up inside the
      * CamelContext this command line tool runs with.

Reply via email to