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 215397bcdc8 camel-jbang - Make camel log read spring boot logs
215397bcdc8 is described below

commit 215397bcdc8b6937c1cec1b4e299d9f90ca0b156
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Apr 29 17:00:12 2024 +0200

    camel-jbang - Make camel log read spring boot logs
---
 .../camel/dsl/jbang/core/commands/action/CamelLogAction.java     | 4 +++-
 .../src/main/resources/log4j2-background.properties              | 2 +-
 .../camel-jbang-core/src/main/resources/log4j2.properties        | 4 ++--
 .../camel-jbang-core/src/main/resources/spring-boot-logback.xml  | 9 +++++----
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
index 7a2a518e82e..2abf9f98437 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelLogAction.java
@@ -446,7 +446,9 @@ public class CamelLogAction extends ActionBaseCommand {
             ts = ts.replace('T', ' ');
             int dot = ts.indexOf('.');
             if (dot != -1) {
-                ts = ts.substring(0, dot + 4);
+                int pos1 = dot + 3; // skip these 6 chars
+                int pos2 = dot + 9;
+                ts = ts.substring(0, pos1) + ts.substring(pos2);
             }
             String after = StringHelper.after(line, "  ");
             return ts + "  " + after;
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2-background.properties
 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2-background.properties
index 6dd65a811f3..691a765a7c4 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2-background.properties
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2-background.properties
@@ -23,7 +23,7 @@ appender.file.createOnDemand = true
 appender.file.append = false
 appender.file.layout.type = PatternLayout
 # logging style that is similar to spring boot
-appender.file.layout.pattern = %style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{Dim} 
%highlight{%5p} %style{%pid}{Magenta} %style{---}{Dim} %style{[%15.15t]}{Dim} 
%style{%-35.35c}{Cyan} : %m%n
+appender.file.layout.pattern = %style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{Dim} 
%highlight{%5p} %style{%pid}{Magenta} %style{---}{Dim} %style{[%15.15t]}{Dim} 
%style{%-40.40c}{Cyan} %style{:}{Dim} %m%n
 
 # log to file
 rootLogger = INFO,file
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2.properties 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2.properties
index bfb1414eaff..db1a2765180 100644
--- a/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2.properties
+++ b/dsl/camel-jbang/camel-jbang-core/src/main/resources/log4j2.properties
@@ -20,7 +20,7 @@ appender.stdout.type = Console
 appender.stdout.name = out
 appender.stdout.layout.type = PatternLayout
 # logging style that is similar to spring boot
-appender.stdout.layout.pattern = %style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{Dim} 
%highlight{%5p} %style{%pid}{Magenta} %style{---}{Dim} %style{[%15.15t]}{Dim} 
%style{%-35.35c}{Cyan} : %m%n
+appender.stdout.layout.pattern = %style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{Dim} 
%highlight{%5p} %style{%pid}{Magenta} %style{---}{Dim} %style{[%15.15t]}{Dim} 
%style{%-40.40c}{Cyan} %style{:}{Dim} %m%n
 
 # file logger
 appender.file.type = File
@@ -30,7 +30,7 @@ appender.file.createOnDemand = true
 appender.file.append = false
 appender.file.layout.type = PatternLayout
 # logging style that is similar to spring boot
-appender.file.layout.pattern = %style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{Dim} 
%highlight{%5p} %style{%pid}{Magenta} %style{---}{Dim} %style{[%15.15t]}{Dim} 
%style{%-35.35c}{Cyan} : %m%n
+appender.file.layout.pattern = %style{%d{yyyy-MM-dd HH:mm:ss.SSS}}{Dim} 
%highlight{%5p} %style{%pid}{Magenta} %style{---}{Dim} %style{[%15.15t]}{Dim} 
%style{%-40.40c}{Cyan} %style{:}{Dim} %m%n
 
 # log to console and file
 rootLogger = INFO,out,file
diff --git 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/spring-boot-logback.xml 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/spring-boot-logback.xml
index 07ec3874841..8e29eaa77b5 100644
--- 
a/dsl/camel-jbang/camel-jbang-core/src/main/resources/spring-boot-logback.xml
+++ 
b/dsl/camel-jbang/camel-jbang-core/src/main/resources/spring-boot-logback.xml
@@ -19,11 +19,12 @@
 -->
 <configuration>
     <include resource="org/springframework/boot/logging/logback/defaults.xml"/>
-    <include 
resource="org/springframework/boot/logging/logback/console-appender.xml" />
-    <include 
resource="org/springframework/boot/logging/logback/file-appender.xml" />
+    <include 
resource="org/springframework/boot/logging/logback/console-appender.xml"/>
+    <include 
resource="org/springframework/boot/logging/logback/file-appender.xml"/>
     <property name="LOG_FILE" 
value="${user.home}${file.separator}.camel${file.separator}${PID}.log"/>
+    <property name="FILE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN}"/> <!-- 
log in color to file -->
     <root level="INFO">
-        <appender-ref ref="CONSOLE" />
-        <appender-ref ref="FILE" />
+        <appender-ref ref="CONSOLE"/>
+        <appender-ref ref="FILE"/>
     </root>
 </configuration>
\ No newline at end of file

Reply via email to