kubernates中的关闭Spring执行器/健康记录器

fnx2tebb  于 2023-05-27  发布在  Spring
关注(0)|答案(1)|浏览(134)

我关闭了www.example.com文件中的spring Boot actuator liveness/readiness日志application.properties,并使用

management.endpoint.health.probes.enabled =true
management.health.livenessstate.enabled=true
management.health.readinessstate.enabled=true

但是它在Kubernate环境中记录健康检查日志...
有没有办法关闭健康检查日志……
感谢您的回复。。

qoefvg9y

qoefvg9y1#

我不确定它是否在Kubernets pod中工作,但我知道它只是禁用控制台日志进行健康检查(路由保持工作)

logging:
 level:
   com:
    my:
      project:
        package:
          configuration:
            RequestLoggingFilterConfiguration: OFF

我的RequestLoggingFilterConfiguration类可以是这样的:

@Configuration
class RequestLoggingFilterConfiguration : OncePerRequestFilter() {
    private val log = LoggerFactory.getLogger(javaClass)

    companion object {
        private val VISIBLE_TYPES: List<MediaType> = listOf(
            MediaType.valueOf("text/*"),
            MediaType.APPLICATION_FORM_URLENCODED,
            MediaType.APPLICATION_JSON,
            MediaType.APPLICATION_XML,
            MediaType.valueOf("application/*+json"),
            MediaType.valueOf("application/*+xml"),
            MediaType.MULTIPART_FORM_DATA
        )
    }

    /**
     All your override methods here
   **/
}

只是你知道这段代码是Kotlin,但使用Sping Boot

相关问题