Skip to content

Add the minRequestDuration attribute to the access log valves - #1172

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:access-log-min-request-duration
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:access-log-min-request-duration

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Adds a minRequestDuration attribute, in milliseconds, to the access log valves (AccessLogValve, ExtendedAccessLogValve and JsonAccessLogValve). Requests that take less time are not logged, so a second access log valve can be used to keep a log of only the slow requests. A request that takes exactly the configured time is logged. The default of 0 logs every request, as before.

The check uses the time that is already passed to log(), in nanoseconds, and is done before anything is formatted, so skipped requests cost almost nothing. It is applied in addition to conditionIf and conditionUnless, which cannot filter on the duration without a custom filter that sets a request attribute. A negative value is rejected.

Tests: TestAccessLogValveMinRequestDuration, which passes the time to the valve so it does not have to wait, and the existing access log tests. Also run against a running Tomcat with a normal and a slow access log, HTTP/1.1 and HTTP/2, async requests, 404 and 500 responses, comparing with main.

Requests that take less time than the configured number of milliseconds
are not logged. This allows a second access log valve to log only the
slow requests. The default of zero logs every request.

The check uses the time that is already passed to log() so nothing is
formatted for the requests that are skipped. It is applied in addition
to conditionIf and conditionUnless.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant