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

时间:2015-11-30 04:48:28

标签: spring-boot

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

3 个答案:

答案 0 :(得分:2)

从类路径中排除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>

答案 1 :(得分:0)

将代码添加到logback.xml

<logger name="org.eclipse.jetty" level="WARN"/>

答案 2 :(得分:0)

从Jetty源代码看起来需要修改jndi的日志记录级别:

<logger name="jndi" level="WARN"/>