spring-boot – 如何在spring boot中禁用jndi调试日志

如何在
spring boot中禁用以下调试日志?

只要对应用程序发出运行状况检查请求,就会显示这些日志

我已经尝试在我们的日志配置文件中将记录器级别设置为这些软件包“org.springframework.jndi”和“javax.naming”的信息,但是每当进行健康检查请求时,上述行仍会出现.

[DEBUG] jndi - InitialContextFactory.getInitialContext()
[DEBUG] jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@756a5bed
[DEBUG] jndi - Looking up name="comp/env/endpoints.enabled"
[DEBUG] jndi - Trying thread context classloader
[DEBUG] jndi - Looking up name="env/endpoints.enabled"
[DEBUG] jndi - InitialContextFactory.getInitialContext()
[DEBUG] jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@6a85ff9f
[DEBUG] jndi - Looking up name="endpoints.enabled"
[DEBUG] jndi - InitialContextFactory.getInitialContext()
[DEBUG] jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@293101e3
[DEBUG] jndi - Looking up name="comp/env/endpoints.health.sensitive"
[DEBUG] jndi - Trying thread context classloader
[DEBUG] jndi - Looking up name="env/endpoints.health.sensitive"
[DEBUG] jndi - InitialContextFactory.getInitialContext()
[DEBUG] jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@235a3b05
[DEBUG] jndi - Looking up name="endpoints.health.sensitive"
[DEBUG] jndi - InitialContextFactory.getInitialContext()
[DEBUG] jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@439cc794
[DEBUG] jndi - Looking up name="comp/env/endpoints.health.sensitive"
[DEBUG] jndi - Trying thread context classloader
[DEBUG] jndi - Looking up name="env/endpoints.health.sensitive"
[DEBUG] jndi - InitialContextFactory.getInitialContext()
[DEBUG] jndi - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@221fa466
[DEBUG] jndi - Looking up name="endpoints.health.sensitive"

最佳答案 从类路径中排除jetty-jndi对我来说是个窍门

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jetty</artifactId>
  <!-- see https://github.com/spring-projects/spring-boot/issues/4710 -->
  <exclusions>
    <exclusion>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-jndi</artifactId>
    </exclusion>
  </exclusions>
</dependency>
点赞