com.raynigon.ecs.logging.access.server.TomcatAccessLogConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecs-logging-access Show documentation
Show all versions of ecs-logging-access Show documentation
The ecs-logging-access is a part of the unit-api
The newest version!
package com.raynigon.ecs.logging.access.server;
import com.raynigon.ecs.logging.access.AccessLogProperties;
import com.raynigon.ecs.logging.access.logback.LogbackAccessValve;
import lombok.RequiredArgsConstructor;
import org.apache.catalina.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import java.util.List;
@Configuration
@AutoConfiguration
@RequiredArgsConstructor
@Order(Ordered.HIGHEST_PRECEDENCE)
@AutoConfigureBefore(ServletWebServerFactoryAutoConfiguration.class)
@ConditionalOnClass(value = {Server.class, WebServerFactoryCustomizer.class})
@EnableConfigurationProperties(AccessLogProperties.class)
public class TomcatAccessLogConfiguration {
@Value("${spring.application.name}")
private String applicationName;
private final AccessLogProperties config;
@Bean
public WebServerFactoryCustomizer tomcatAccessLogCustomizer(List accessValves) {
return factory -> factory.addContextValves(accessValves.toArray(AccessValve[]::new));
}
@Bean
public AccessValve accessLogValve() {
return new LogbackAccessValve(config, applicationName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy