: HOWTO log only slow requests in apache httpd Is there a way to specify a condition in apache httpd access_log to persist only requests which took longer than 500ms to process?
Is there a way to specify a condition in apache httpd access_log to persist only requests which took longer than 500ms to process?
More posts by @Kristi941
1 Comments
Sorted by latest first Latest Oldest Best
The CustomLog directive allows you to set a condition (in an optional 3rd argument) that is used to control when the request is logged. (On Apache 2.4+ this can take the form of an Apache Expression.) However, this condition is generally based on a property of the request (file type, request header, etc.), rather than something that is associated with the response. (Although it does seem possible to create a condition based on the HTTP response status, as this is explicitly made available in the REQUEST_STATUS server variable.)
However, I don't see a way to create a conditon based on the server response time. (?)
A workaround might be to specifically include this information in your access log using the format string %msT (if you specifically want this logged as milliseconds) in a custom log format. You can then filter this information using a log file analyzer.
%T - The time taken to serve the request, in seconds.
%{UNIT}T - The time taken to serve the request, in a time unit given by UNIT. Valid units are ms for milliseconds, us for microseconds, and s for seconds. Using s gives the same result as %T without any format; using us gives the same result as %D. Combining %T with a unit is available in 2.4.13 and later.
Reference: httpd.apache.org/docs/current/mod/mod_log_config.html#formats
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.