logback-access-spring-boot-starter
logback-access-spring-boot-starter copied to clipboard
Exclude health check probes from access logs
Hi! It's common to have a load balancer or container orchestration system probing that your application is ready to serve traffic. At the moment, I'm using Janino to exclude those access logs from appearing, but I believe it's such a common issue that it would be helpful to provide a Spring property to enable/disable excluding the health check access logs. The request uri to be excluded would be the actuator health endpoint, and only when the response is 200 OK. That way, if something goes wrong, you still see the errors. But you no longer get an infinite log full of GET /health 200 OK.
I'd be happy to contribute, but I don't know how that can be done in this library.
Hello!
Logback access filters are designed to solve this problem. Can you more clearly explain your use case with janino? I'm a little puzzled, because logback also uses janino for filters:
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator name="EvalActuator">
<expression>
!((event.getStatusCode() == 200) && (event.getRequestURI().startsWith("/actuator"))
</expression>
</evaluator>
<onMismatch>DENY</onMismatch>
</filter>
actuators context is customizable... I think it would be much better to use a custom spring boot property, something like spring.logging.access.exclude-url-patterns
Another way to configure the EvaluatorFilter
:
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator class="ch.qos.logback.access.net.URLEvaluator">
<URL>/health</URL>
<!-- add more URLs as needed -->
</evaluator>
<OnMismatch>NEUTRAL</OnMismatch>
<OnMatch>DENY</OnMatch>
</filter>
Hi @fiunchinho I would like to know how you enabled actuator health logs to be printed with status?