com.healthy.common.log.AccessLogAutoConfiguration Maven / Gradle / Ivy
package com.healthy.common.log;
import com.healthy.common.log.access.filter.AccessLogFilter;
import com.healthy.common.log.access.handler.AccessLogHandler;
import com.healthy.common.log.access.properties.AccessLogProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
/**
* 访问日志自动配置
*
* @author xm.z
*/
@Slf4j
@RequiredArgsConstructor
@ConditionalOnWebApplication
@EnableConfigurationProperties(AccessLogProperties.class)
@ConditionalOnProperty(prefix = AccessLogProperties.PREFIX, name = "enabled", matchIfMissing = true,
havingValue = "true")
public class AccessLogAutoConfiguration {
private final AccessLogHandler> accessLogService;
private final AccessLogProperties accessLogProperties;
@Bean
@ConditionalOnClass(AccessLogHandler.class)
public FilterRegistrationBean accessLogFilterRegistrationBean() {
log.debug("access log 记录拦截器已开启====");
FilterRegistrationBean registrationBean = new FilterRegistrationBean<>(
new AccessLogFilter(accessLogService, accessLogProperties.getIgnoreUrlPatterns()));
registrationBean.setOrder(-10);
return registrationBean;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy