This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 9ba3a65dee17 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)
9ba3a65dee17 is described below
commit 9ba3a65dee17adfee6ec4589d43cb9d7d01e666c
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 a042542637b4..6614df67c1c6 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
@@ -1709,14 +1709,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 f31ff10ddcae..deda5b3178f2 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
@@ -173,6 +173,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.