This is an automated email from the ASF dual-hosted git repository.
fmariani 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 d50c16705c9 CAMEL-22964 SB platform-http: undertow access log managed
by camel logging
d50c16705c9 is described below
commit d50c16705c9abbc39551f2743c706e6bbd1e50da
Author: Claudio Miranda <[email protected]>
AuthorDate: Thu Feb 12 16:23:09 2026 +0000
CAMEL-22964 SB platform-http: undertow access log managed by camel logging
https://issues.apache.org/jira/browse/CAMEL-22964
- rename the property from
camel.component.platform-http.server.accesslog.undertow.use-camel-logging
to
camel.component.platform-http.server.undertow.accesslog.use-camel-logging
- add a similar property to the management undertow server
management.server.undertow.accesslog.use-camel-logging
---
.../src/main/docs/platform-http.adoc | 10 +++++----
.../src/main/docs/platform-http.json | 4 ++--
.../customizer/UndertowAccessLogConfiguration.java | 5 +++--
.../customizer/UndertowAccessLogProperties.java | 2 +-
.../src/main/docs/spring-boot.adoc | 25 +++++++++++++++++-----
.../src/main/docs/spring-boot.json | 6 ++++++
.../ManagementAccessLogConfiguration.java | 24 +++++++++++++++++++--
.../accesslog/ManagementAccessLogProperties.java | 10 +++++++++
8 files changed, 70 insertions(+), 16 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
index d1f759cc493..24898a54bba 100644
---
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
@@ -1,4 +1,4 @@
-= HTTP
+= Platform HTTP
//Manually maintained attributes
:artifactid: camel-platform-http
:shortname: platform-http
@@ -11,12 +11,12 @@ The Platform HTTP starter provides Spring Boot
auto-configuration for the Camel
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
+# disable the Undertow's own access log handler.
server.undertow.accesslog.enabled=false
-# optionally sets a log pattern (optional)
+# 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
+camel.component.platform-http.server.undertow.accesslog.use-camel-logging=true
----
The access log category is `io.undertow.accesslog` and is logged at `INFO`
level.
@@ -61,3 +61,5 @@ If you want to control the undertow access log category:
</root>
</configuration>
----
+
+The HTTP access log message pattern may be controlled by the property:
`server.undertow.accesslog.pattern` whose default value is `common`.
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 b611b25426d..641e67f14d7 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
@@ -12,7 +12,7 @@
"sourceMethod": "getCustomizer()"
},
{
- "name": "camel.component.platform-http.server.accesslog.undertow",
+ "name": "camel.component.platform-http.server.undertow.accesslog",
"type":
"org.apache.camel.component.platform.http.springboot.customizer.UndertowAccessLogProperties",
"sourceType":
"org.apache.camel.component.platform.http.springboot.customizer.UndertowAccessLogProperties"
}
@@ -76,7 +76,7 @@
"defaultValue": true
},
{
- "name":
"camel.component.platform-http.server.accesslog.undertow.use-camel-logging",
+ "name":
"camel.component.platform-http.server.undertow.accesslog.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",
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
index a1eee5276c1..33f0bca01b9 100644
---
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
@@ -16,6 +16,7 @@
*/
package org.apache.camel.component.platform.http.springboot.customizer;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -37,12 +38,12 @@ import
io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver;
@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"),
+ @ConditionalOnProperty(name =
"camel.component.platform-http.server.undertow.accesslog.use-camel-logging",
havingValue = "true"),
})
public class UndertowAccessLogConfiguration {
@Bean
- WebServerFactoryCustomizer<UndertowServletWebServerFactory>
undertowManagementAccessLogCustomizer(Environment env) {
+ WebServerFactoryCustomizer<UndertowServletWebServerFactory>
undertowServerAccessLogCustomizer(Environment env) {
return new
WebServerFactoryCustomizer<UndertowServletWebServerFactory>() {
@Override
public void customize(UndertowServletWebServerFactory factory) {
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
index 616f7c18712..b217e504d70 100644
---
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
@@ -21,7 +21,7 @@ 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")
+@ConfigurationProperties(prefix =
"camel.component.platform-http.server.undertow.accesslog")
public class UndertowAccessLogProperties {
/**
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
index d73c825ce68..7fb0591679d 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
@@ -69,7 +69,7 @@ public class MyRoute extends RouteBuilder {
Then these routes will be started automatically.
You can customize the Camel application in the `application.properties`
-or `application.yml` file.
+or `application.yml` file.
// spring-boot-auto-configure options: START
@@ -152,7 +152,7 @@ to
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-e
Boot external configuration] (like properties placeholders, OS
environment variables or system properties) with
the Camel properties support. It basically means
-that any property defined in `application.properties` file:
+that any property defined in `application.properties` file:
[source,properties]
----
@@ -487,6 +487,21 @@ management.server.accesslog.enabled=false
Result: Main app logs to `logs/access_log.log`, actuator has no access logs.
+==== Camel Logging to Control Management Access Log
+
+This is valid only when using `spring-boot-starter-undertow`.
+
+If you want to defer the http access log control to whatever camel logging
mechanism, you have to set
`management.server.undertow.accesslog.use-camel-logging=true`.
+Optionally you can set a message pattern with
`management.server.accesslog.pattern=combined`.
+
+Example:
+[source,properties]
+----
+management.server.undertow.accesslog.use-camel-logging=true
+management.server.accesslog.pattern=combined
+----
+
+
== Virtual Threads Support
Camel Spring Boot provides comprehensive support for JDK 21+ Virtual Threads,
offering significant performance improvements for I/O-intensive applications.
Virtual threads are lightweight threads that can dramatically reduce memory
overhead and improve scalability compared to traditional platform threads.
@@ -596,7 +611,7 @@ If you need to manually configure specific components for
virtual threads, you c
----
@Configuration
public class VirtualThreadConfig {
-
+
@Bean
@ConditionalOnProperty(name = "spring.threads.virtual.enabled",
havingValue = "true")
public TaskExecutor customTaskExecutor() {
@@ -638,11 +653,11 @@ camel.main.routes-include-pattern=classpath:routes/*
----
@SpringBootApplication
public class VirtualThreadsApplication {
-
+
public static void main(String[] args) {
SpringApplication.run(VirtualThreadsApplication.class, args);
}
-
+
@Component
public static class ApiRoutes extends RouteBuilder {
@Override
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json
b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 3c29c379cda..f339b37a2bf 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -2172,6 +2172,12 @@
"sourceType":
"org.apache.camel.spring.boot.actuate.accesslog.ManagementAccessLogProperties",
"defaultValue": true
},
+ {
+ "name": "management.server.accesslog.pattern",
+ "type": "java.lang.String",
+ "sourceType":
"org.apache.camel.spring.boot.actuate.accesslog.ManagementAccessLogProperties",
+ "defaultValue": "common"
+ },
{
"name": "camel.main.main-run-controller",
"type": "java.lang.Boolean",
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogConfiguration.java
index 8cf6231a380..dd3b9ee1702 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogConfiguration.java
@@ -17,6 +17,7 @@
package org.apache.camel.spring.boot.actuate.accesslog;
import org.apache.catalina.valves.AccessLogValve;
+import org.springframework.beans.factory.annotation.Value;
import
org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -28,6 +29,9 @@ import
org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import io.undertow.server.handlers.accesslog.AccessLogHandler;
+import io.undertow.server.handlers.accesslog.JBossLoggingAccessLogReceiver;
+
/**
* Management context configuration for controlling access logging on the
management server.
* <p>
@@ -41,17 +45,33 @@ import org.springframework.context.annotation.Configuration;
public class ManagementAccessLogConfiguration {
/**
- * Undertow-specific configuration to disable access logging in the
management context.
+ * Undertow-specific configuration.
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(name = "io.undertow.Undertow")
- @ConditionalOnProperty(name = "management.server.accesslog.enabled",
havingValue = "false")
static class UndertowAccessLogCustomizerConfiguration {
+ /**
+ * Disable access logging in the management context.
+ */
@Bean
+ @ConditionalOnProperty(name = "management.server.accesslog.enabled",
havingValue = "false")
WebServerFactoryCustomizer<UndertowServletWebServerFactory>
undertowManagementAccessLogCustomizer() {
return factory -> factory.setAccessLogEnabled(false);
}
+
+ /**
+ * Undertow HTTP access log is managed by whatever camel logging
mechanism.
+ */
+ @Bean
+ @ConditionalOnProperty(name =
"management.server.undertow.accesslog.use-camel-logging", havingValue = "true")
+ public WebServerFactoryCustomizer<UndertowServletWebServerFactory>
managementAccessLogProvider(
+ @Value("${management.server.accesslog.pattern:common}") String
pattern) {
+ return factory ->
factory.addDeploymentInfoCustomizers(deploymentInfo -> {
+ deploymentInfo.addInitialHandlerChainWrapper(handler -> new
AccessLogHandler(handler,
+ new JBossLoggingAccessLogReceiver(), pattern,
AccessLogHandler.class.getClassLoader()));
+ });
+ }
}
/**
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogProperties.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogProperties.java
index 9c9c57055b3..439305cd84e 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogProperties.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/actuate/accesslog/ManagementAccessLogProperties.java
@@ -29,6 +29,7 @@ public class ManagementAccessLogProperties {
* access logs are disabled for actuator endpoints.
*/
private boolean enabled = true;
+ private String pattern = "common";
public boolean isEnabled() {
return enabled;
@@ -37,4 +38,13 @@ public class ManagementAccessLogProperties {
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
}