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-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 0f52a544db5 CAMEL-22964 SB platform-http: undertow access log managed 
by camel logging (#1652)
0f52a544db5 is described below

commit 0f52a544db54a30ac813528d0d6a7e0a68a90d6f
Author: Claudio Miranda <[email protected]>
AuthorDate: Sat Feb 7 04:25:08 2026 -0300

    CAMEL-22964 SB platform-http: undertow access log managed by camel logging 
(#1652)
    
    https://issues.apache.org/jira/browse/CAMEL-22964
---
 .../src/main/docs/platform-http.adoc               | 63 ++++++++++++++++++++++
 .../src/main/docs/platform-http.json               | 25 +++++----
 .../customizer/UndertowAccessLogConfiguration.java | 61 +++++++++++++++++++++
 .../customizer/UndertowAccessLogProperties.java    | 39 ++++++++++++++
 ...rk.boot.autoconfigure.AutoConfiguration.imports |  3 +-
 5 files changed, 181 insertions(+), 10 deletions(-)

diff --git 
a/components-starter/camel-platform-http-starter/src/main/docs/platform-http.adoc
 
b/components-starter/camel-platform-http-starter/src/main/docs/platform-http.adoc
new file mode 100644
index 00000000000..d1f759cc493
--- /dev/null
+++ 
b/components-starter/camel-platform-http-starter/src/main/docs/platform-http.adoc
@@ -0,0 +1,63 @@
+= HTTP
+//Manually maintained attributes
+:artifactid: camel-platform-http
+:shortname: platform-http
+:camel-spring-boot-name: platform-http
+
+The Platform HTTP starter provides Spring Boot auto-configuration for the 
Camel Platform HTTP component.
+
+== Undertow Access Log
+
+You can enable Undertow access log to be managed by whatever logging library 
you have in your camel application, you have to set the following parameters:
+[source,properties]
+----
+# disable the undertow access log handler
+server.undertow.accesslog.enabled=false
+# optionally sets a log pattern (optional)
+server.undertow.accesslog.pattern="%r" %s (%D ms)
+# enable camel to control the logging
+camel.component.platform-http.server.accesslog.undertow.use-camel-logging=true
+----
+
+The access log category is `io.undertow.accesslog` and is logged at `INFO` 
level.
+
+This way you can defer the access log control to the same logging framework in 
your camel application.
+
+Let's say you are using logback, then this is the configuration.
+[source,xml]
+----
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
+----
+
+If you want to control the undertow access log category:
+[source,xml]
+----
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - 
%msg%n</pattern>
+        </encoder>
+        <file>undertow-accesslog.log</file>
+    </appender>
+    <logger name="io.undertow.accesslog" level="info" additivity="false">
+        <appender-ref ref="FILE" />
+    </logger>
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
+----
diff --git 
a/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
 
b/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
index d304354f5d2..ad5a5002336 100644
--- 
a/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
+++ 
b/components-starter/camel-platform-http-starter/src/main/docs/platform-http.json
@@ -9,7 +9,12 @@
       "name": "camel.component.platform-http.customizer",
       "type": 
"org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon$CustomizerProperties",
       "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration",
-      "sourceMethod": "getCustomizer()"
+      "sourceMethod": "public 
org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon.CustomizerProperties
 getCustomizer() "
+    },
+    {
+      "name": "camel.component.platform-http.server.accesslog.undertow",
+      "type": 
"org.apache.camel.component.platform.http.springboot.customizer.UndertowAccessLogProperties",
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.customizer.UndertowAccessLogProperties"
     }
   ],
   "properties": [
@@ -17,15 +22,13 @@
       "name": "camel.component.platform-http.autowired-enabled",
       "type": "java.lang.Boolean",
       "description": "Whether autowiring is enabled. This is used for 
automatic autowiring options (the option must be marked as autowired) by 
looking up in the registry to find if there is a single instance of matching 
type, which then gets configured on the component. This can be used for 
automatic configuring JDBC data sources, JMS connection factories, AWS Clients, 
etc.",
-      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration",
-      "defaultValue": true
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration"
     },
     {
       "name": "camel.component.platform-http.bridge-error-handler",
       "type": "java.lang.Boolean",
       "description": "Allows for bridging the consumer to the Camel routing 
Error Handler, which mean any exceptions (if possible) occurred while the Camel 
consumer is trying to pickup incoming messages, or the likes, will now be 
processed as a message and handled by the routing Error Handler. Important: 
This is only possible if the 3rd party component allows Camel to be alerted if 
an exception was thrown. Some components handle this internally only, and 
therefore bridgeErrorHandler is n [...]
-      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration",
-      "defaultValue": false
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration"
     },
     {
       "name": "camel.component.platform-http.customizer.enabled",
@@ -48,8 +51,7 @@
       "name": "camel.component.platform-http.handle-write-response-error",
       "type": "java.lang.Boolean",
       "description": "When Camel is complete processing the message, and the 
HTTP server is writing response. This option controls whether Camel should 
catch any failure during writing response and store this on the Exchange, which 
allows onCompletion\/UnitOfWork to regard the Exchange as failed and have 
access to the caused exception from the HTTP server.",
-      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration",
-      "defaultValue": false
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration"
     },
     {
       "name": "camel.component.platform-http.header-filter-strategy",
@@ -67,8 +69,13 @@
       "name": "camel.component.platform-http.server-request-validation",
       "type": "java.lang.Boolean",
       "description": "Whether HTTP server should do preliminary validation of 
incoming requests, validating if Content-Type\/Accept header, matches what is 
allowed according to consumes\/produces configuration (if set). If validation 
fails HTTP Status 415\/406 is returned. The HTTP server performs this 
validation before Camel is involved, and as such if validation fails then Camel 
is never activated. Setting this option to false, allows Camel to process any 
incoming requests such as to d [...]
-      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration",
-      "defaultValue": true
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConfiguration"
+    },
+    {
+      "name": 
"camel.component.platform-http.server.accesslog.undertow.use-camel-logging",
+      "type": "java.lang.Boolean",
+      "description": "Use camel logging for undertow http access log.",
+      "sourceType": 
"org.apache.camel.component.platform.http.springboot.customizer.UndertowAccessLogProperties"
     }
   ],
   "hints": [],
diff --git 
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/customizer/UndertowAccessLogConfiguration.java
 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/customizer/UndertowAccessLogConfiguration.java
new file mode 100644
index 00000000000..a1eee5276c1
--- /dev/null
+++ 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/customizer/UndertowAccessLogConfiguration.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.platform.http.springboot.customizer;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import 
org.springframework.boot.autoconfigure.condition.ConditionalOnProperties;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import 
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import 
org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+
+import io.undertow.server.handlers.accesslog.AccessLogHandler;
+import io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver;
+
+/**
+ * Undertow specific configuration to use camel logging for HTTP access log.
+ */
+@Configuration(proxyBeanMethods = false)
+@EnableConfigurationProperties(UndertowAccessLogProperties.class)
+@ConditionalOnClass(name = "io.undertow.Undertow")
+@ConditionalOnProperties( {
+    @ConditionalOnProperty(name = "server.undertow.accesslog.enabled", 
havingValue = "false"),
+    @ConditionalOnProperty(name = 
"camel.component.platform-http.server.accesslog.undertow.use-camel-logging", 
havingValue = "true"),
+})
+public class UndertowAccessLogConfiguration {
+
+    @Bean
+    WebServerFactoryCustomizer<UndertowServletWebServerFactory> 
undertowManagementAccessLogCustomizer(Environment env) {
+        return new 
WebServerFactoryCustomizer<UndertowServletWebServerFactory>() {
+            @Override
+            public void customize(UndertowServletWebServerFactory factory) {
+                factory.addDeploymentInfoCustomizers(deploymentInfo -> {
+                    deploymentInfo.addInitialHandlerChainWrapper(handler -> {
+                        JBossLoggingAccessLogReceiver jbossLogReceiver = new 
JBossLoggingAccessLogReceiver();
+                        // undertow specific HTTP log message pattern
+                        // 
https://github.com/undertow-io/undertow/blob/2.3.22.Final/core/src/main/java/io/undertow/server/handlers/accesslog/AccessLogHandler.java
+                        String pattern = 
env.getProperty("server.undertow.accesslog.pattern", "common");
+                        return new AccessLogHandler(handler, jbossLogReceiver, 
pattern, getClass().getClassLoader());
+                    });
+                });
+            }
+        };
+    }
+}
\ No newline at end of file
diff --git 
a/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/customizer/UndertowAccessLogProperties.java
 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/customizer/UndertowAccessLogProperties.java
new file mode 100644
index 00000000000..616f7c18712
--- /dev/null
+++ 
b/components-starter/camel-platform-http-starter/src/main/java/org/apache/camel/component/platform/http/springboot/customizer/UndertowAccessLogProperties.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.platform.http.springboot.customizer;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * Configuration properties to customize undertow server to use camel logging 
to log HTTP accesslog.
+ */
+@ConfigurationProperties(prefix = 
"camel.component.platform-http.server.accesslog.undertow")
+public class UndertowAccessLogProperties {
+
+    /**
+     * Use camel logging for undertow http access log.
+     */
+    private boolean useCamelLogging;
+
+    public boolean isUseCamelLogging() {
+        return useCamelLogging;
+    }
+
+    public void setUseCamelLogging(boolean enabled) {
+        this.useCamelLogging = enabled;
+    }
+}
diff --git 
a/components-starter/camel-platform-http-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
 
b/components-starter/camel-platform-http-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 84a0a5df88d..c2b81150523 100644
--- 
a/components-starter/camel-platform-http-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ 
b/components-starter/camel-platform-http-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -19,4 +19,5 @@ 
org.apache.camel.component.platform.http.springboot.PlatformHttpComponentConvert
 
org.apache.camel.component.platform.http.springboot.PlatformHttpComponentAutoConfiguration
 
org.apache.camel.component.platform.http.springboot.SpringBootPlatformHttpAutoConfiguration
 
org.apache.camel.component.platform.http.springboot.SpringBootPlatformWebMvcConfiguration
-org.apache.camel.component.platform.http.springboot.actuate.metrics.undertow.UndertowMetricsAutoConfiguration
\ No newline at end of file
+org.apache.camel.component.platform.http.springboot.actuate.metrics.undertow.UndertowMetricsAutoConfiguration
+org.apache.camel.component.platform.http.springboot.customizer.UndertowAccessLogConfiguration
\ No newline at end of file

Reply via email to