Skip to main content
 首页 » 编程设计

spring-boot之如何在 Spring Boot 中禁用 jndi 调试日志

2024年08月15日9youxin

如何在 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>