【新增】yudao.access-log.enable 访问日志的开关,默认在 local 环境关闭记录访问日志

This commit is contained in:
YunaiV 2022-06-25 10:50:05 +08:00
parent 3774afe553
commit 383ff130b9
3 changed files with 7 additions and 1 deletions

View File

@ -5,13 +5,14 @@ import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServi
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl; import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLogFrameworkServiceImpl;
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService;
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl; import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkServiceImpl;
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
import cn.iocoder.yudao.framework.web.config.WebProperties; import cn.iocoder.yudao.framework.web.config.WebProperties;
import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration; import cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration;
import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi; import cn.iocoder.yudao.module.infra.api.logger.ApiAccessLogApi;
import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi; import cn.iocoder.yudao.module.infra.api.logger.ApiErrorLogApi;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -36,6 +37,7 @@ public class YudaoApiLogAutoConfiguration {
* 创建 ApiAccessLogFilter Bean记录 API 请求日志 * 创建 ApiAccessLogFilter Bean记录 API 请求日志
*/ */
@Bean @Bean
@ConditionalOnProperty(prefix = "yudao.access-log", value = "enable", matchIfMissing = true) // 允许使用 yudao.access-log.enable=false 禁用访问日志
public FilterRegistrationBean<ApiAccessLogFilter> apiAccessLogFilter(WebProperties webProperties, public FilterRegistrationBean<ApiAccessLogFilter> apiAccessLogFilter(WebProperties webProperties,
@Value("${spring.application.name}") String applicationName, @Value("${spring.application.name}") String applicationName,
ApiAccessLogFrameworkService apiAccessLogFrameworkService) { ApiAccessLogFrameworkService apiAccessLogFrameworkService) {

View File

@ -134,4 +134,6 @@ yudao:
exclude-urls: # 如下两个 url仅仅是为了演示去掉配置也没关系 exclude-urls: # 如下两个 url仅仅是为了演示去掉配置也没关系
- ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求 - ${spring.boot.admin.context-path}/** # 不处理 Spring Boot Admin 的请求
- ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求 - ${management.endpoints.web.base-path}/** # 不处理 Actuator 的请求
access-log: # 访问日志的配置项
enable: false
demo: false # 关闭演示模式 demo: false # 关闭演示模式

View File

@ -150,6 +150,8 @@ yudao:
pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify pay-notify-url: http://niubi.natapp1.cc/api/pay/order/notify
pay-return-url: http://niubi.natapp1.cc/api/pay/order/return pay-return-url: http://niubi.natapp1.cc/api/pay/order/return
refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify refund-notify-url: http://niubi.natapp1.cc/api/pay/refund/notify
access-log: # 访问日志的配置项
enable: false
demo: false # 关闭演示模式 demo: false # 关闭演示模式
justauth: justauth: