在我的 application.properties 中,我已配置日志记录如下:
logging.level.org.springframework.web=TRACE
这是故意的,应该保持原样。当调用 Actuator 端点(例如 /actuator/health)时,日志中会写入许多条目:
LOCAL INFO [io-18080-exec-3,] AccessLogFilter : servletRequest-Attribute: null
LOCAL INFO [io-18080-exec-3,] AccessLogFilter : Request-Uri: /actuator/health
LOCAL INFO [io-18080-exec-3,] AccessLogFilter : servletRequest: org.apache.catalina.connector.RequestFacade@4783a4a1
LOCAL TRACE [io-18080-exec-3,] DispatcherServlet : GET "/actuator/health", parameters={}, headers={masked} in DispatcherServlet 'dispatcherServlet'
LOCAL TRACE [io-18080-exec-3,] RequestResponseBodyMethodProcessor : Read "application/vnd.vendor-onboarding.v1+json;charset=UTF-8" to [{}]
LOCAL TRACE [io-18080-exec-3,] HandlerMethod : Arguments: [org.apache.catalina.connector.RequestFacade@4783a4a1, {}]
LOCAL DEBUG [io-18080-exec-3,] HttpEntityMethodProcessor : Using 'application/vnd.spring-boot.actuator.v3+json', given [*/*] and supported [application/vnd.spring-boot.actuator.v3+json, application/vnd.spring-boot.actuator.v2+json, application/json]
LOCAL TRACE [io-18080-exec-3,] HttpEntityMethodProcessor : Writing [org.springframework.boot.actuate.health.SystemHealth@782d7d50]
LOCAL TRACE [io-18080-exec-3,] RequestMappingHandlerAdapter : Applying default cacheSeconds=-1
LOCAL TRACE [io-18080-exec-3,] DispatcherServlet : No view rendering, null ModelAndView returned.
LOCAL DEBUG [io-18080-exec-3,] DispatcherServlet : Completed 200 OK, headers={masked}
如何防止这种情况发生?我想关闭特定端点的日志记录。
你可以尝试这样的事情
management.health.<indicator_identifier>.enabled
在您的 application.yml 文件中,如此处所述 https://www.baeldung.com/spring-boot-health-indicators#2-disabling-the-indicator