Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= HTTP
= Platform HTTP
//Manually maintained attributes
:artifactid: camel-platform-http
:shortname: platform-http
Expand All @@ -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.
Expand Down Expand Up @@ -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`.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,12 +38,12 @@
@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* 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 {

/**
Expand Down
25 changes: 20 additions & 5 deletions core/camel-spring-boot/src/main/docs/spring-boot.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
----
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions core/camel-spring-boot/src/main/docs/spring-boot.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,6 +29,9 @@
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>
Expand All @@ -41,17 +45,33 @@
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()));
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,4 +38,13 @@ public boolean isEnabled() {
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getPattern() {
return pattern;
}

public void setPattern(String pattern) {
this.pattern = pattern;
}

}