spring - 如何在 Spring Boot 中启用 Logback 访问?
问题描述
我正在尝试在 Spring Boot 应用程序中启用 logback-access 以记录所有命中应用程序的 http 请求。
我尝试过使用:https ://github.com/akihyro/logback-access-spring-boot-starter
添加示例中显示的 XML 文件没有任何作用,是否需要添加更多内容才能启用?
欢迎任何其他达到相同结果的建议:)
解决方案
您仍然需要将 bean 连接到您的应用程序......就像这个代码片段将过滤器连接到您的应用程序:
@SpringBootApplication
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args);
}
// ... your other methods here
@Bean
public CommonsRequestLoggingFilter logFilter() {
CommonsRequestLoggingFilter filter = new CommonsRequestLoggingFilter();
filter.setIncludeQueryString(true);
return filter;
}
}
推荐阅读
- python - 除非在其中一个单元测试中导入,否则 Pytest-cov 不考虑文件进行覆盖率分析?
- continuous-integration - Azure 数据工厂如何使用 DevOps 将警报和指标部署到其他环境
- java - 单击按钮时打开 JTextArea
- regex - 使用 awk 和 sed 进行日志解析
- python - 使用嵌套的 while 循环而不是 for 循环
- git - git:如何应用有冲突的补丁?
- azure-resource-manager - 将静态出站 IP 地址分配给 azure 容器实例
- angular - 使用 Angular Service Worker 从所有 API 中预取数据
- airflow - 在气流的 email_operator 中,如果我们向和 cc 提供相同的电子邮件 ID,它不起作用?
- java - 为什么我的 GeoLocation 距离值与我的编程任务的给定值偏差如此之小?