You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/01/23 14:24:59 UTC

[camel] branch master updated: CAMEL-16072: Reduce logging noise on startup. Fix startup time to be total time, and output individual time per phase.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0c1026d  CAMEL-16072: Reduce logging noise on startup. Fix startup time to be total time, and output individual time per phase.
0c1026d is described below

commit 0c1026d6ff3bb0fb3344c05c58558447eb6dd0a2
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sat Jan 23 15:24:29 2021 +0100

    CAMEL-16072: Reduce logging noise on startup. Fix startup time to be total time, and output individual time per phase.
---
 .../camel/impl/engine/AbstractCamelContext.java    | 24 ++++++++++++++--------
 .../apache/camel/main/DefaultRoutesCollector.java  |  6 +++---
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 97ddf84..8fe876d 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -314,6 +314,7 @@ public abstract class AbstractCamelContext extends BaseService
     private ShutdownRoute shutdownRoute = ShutdownRoute.Default;
     private ShutdownRunningTask shutdownRunningTask = ShutdownRunningTask.CompleteCurrentTaskOnly;
     private Debugger debugger;
+    private long buildTaken;
     private long initTaken;
     private long startDate;
 
@@ -2535,6 +2536,8 @@ public abstract class AbstractCamelContext extends BaseService
 
     @Override
     public void doBuild() throws Exception {
+        StopWatch watch = new StopWatch();
+
         // auto-detect step recorder from classpath if none has been explicit configured
         if (startupStepRecorder.getClass().getSimpleName().equals("DefaultStartupStepRecorder")) {
             StartupStepRecorder fr = getBootstrapFactoryFinder()
@@ -2587,6 +2590,9 @@ public abstract class AbstractCamelContext extends BaseService
         }
 
         startupStepRecorder.endStep(step);
+
+        buildTaken = watch.taken();
+        LOG.debug("Apache Camel {} ({}) built in {}", getVersion(), getName(), TimeUtils.printDuration(buildTaken));
     }
 
     @Override
@@ -2740,14 +2746,11 @@ public abstract class AbstractCamelContext extends BaseService
         startupStepRecorder.endStep(step);
 
         initTaken = watch.taken();
-        LOG.info("Apache Camel {} ({}) initialized in {}", getVersion(), getName(), TimeUtils.printDuration(initTaken));
+        LOG.debug("Apache Camel {} ({}) initialized in {}", getVersion(), getName(), TimeUtils.printDuration(initTaken));
     }
 
     @Override
     protected void doStart() throws Exception {
-        if (!"DefaultStartupStepRecorder".equals(startupStepRecorder.getClass().getSimpleName())) {
-            LOG.info("Using startup recorder: {}", startupStepRecorder);
-        }
         StartupStep step = startupStepRecorder.beginStep(CamelContext.class, getName(), "Start CamelContext");
 
         try {
@@ -2880,10 +2883,13 @@ public abstract class AbstractCamelContext extends BaseService
         }
 
         long taken = stopWatch.taken();
-        long total = initTaken + taken;
+        long max = buildTaken + initTaken + taken;
+        String total = TimeUtils.printDuration(max);
         String start = TimeUtils.printDuration(taken);
-        String boot = TimeUtils.printDuration(total);
-        LOG.info("Apache Camel {} ({}) started in {} (with init {})", getVersion(), getName(), start, boot);
+        String init = TimeUtils.printDuration(initTaken);
+        String built = TimeUtils.printDuration(buildTaken);
+        LOG.info("Apache Camel {} ({}) started in {} (build:{} init:{} start:{})", getVersion(), getName(), total, built, init,
+                start);
     }
 
     protected void doStartCamel() throws Exception {
@@ -2987,8 +2993,8 @@ public abstract class AbstractCamelContext extends BaseService
         } else {
             // log if stream caching is not in use as this can help people to
             // enable it if they use streams
-            LOG.info("StreamCaching is not in use. If using streams then it's recommended to enable stream caching."
-                     + " See more details at http://camel.apache.org/stream-caching.html");
+            LOG.debug("StreamCaching is not in use. If using streams then it's recommended to enable stream caching."
+                      + " See more details at http://camel.apache.org/stream-caching.html");
         }
 
         if (isAllowUseOriginalMessage()) {
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
index bda912e..d9dd488 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultRoutesCollector.java
@@ -144,7 +144,7 @@ public class DefaultRoutesCollector implements RoutesCollector {
                 log.info("Loaded {} ({} millis) additional Camel XML route templates from: {}", count, watch.taken(),
                         directory);
             } else {
-                log.info("No additional Camel XML route templates discovered from: {}", directory);
+                log.debug("No additional Camel XML route templates discovered from: {}", directory);
             }
         }
 
@@ -183,7 +183,7 @@ public class DefaultRoutesCollector implements RoutesCollector {
             if (count > 0) {
                 log.info("Loaded {} ({} millis) additional Camel XML routes from: {}", count, watch.taken(), directory);
             } else {
-                log.info("No additional Camel XML routes discovered from: {}", directory);
+                log.debug("No additional Camel XML routes discovered from: {}", directory);
             }
         }
 
@@ -221,7 +221,7 @@ public class DefaultRoutesCollector implements RoutesCollector {
             if (count > 0) {
                 log.info("Loaded {} ({} millis) additional Camel XML rests from: {}", count, watch.taken(), directory);
             } else {
-                log.info("No additional Camel XML rests discovered from: {}", directory);
+                log.debug("No additional Camel XML rests discovered from: {}", directory);
             }
         }