You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Rainer Jung <ra...@kippdata.de> on 2022/05/27 13:55:53 UTC
Request-ID added to mod_jk log
Hi all,
I added logging of a request id to mod_jk log to ease correlation with
other Apache logs, like the access log. It was motivated by a discussion
with Chris, although the end result wasn't exactly what he liked most.
Currently there is no useful ID logged for IIS, because I don't know how
to get one and was to lazy to generate one myself (eg. using start time
plus an incremented 64 Bit atomic or alternatively get one from a header).
For Apache by default I use the one generated by mod_unique_id, but one
can take it from a different env var by setting JkRequestIdIndicator.
Such an env var can be populated eg. by copying in an ID that comes from
a proxy in front via a request header.
Roughly 300 log statements have been converted to using the ID, about
450 are remaining not using it. Those are either not in a request
context (startup, initialization) or in low level functions, to which I
didn't want to pass down the higher level request service struct.
You might want to experiment with it.
Probably we could release a 1.2.49 with it. Last release was more than a
year ago. No hurry though.
I someone has a good idea how to handle IIS, let me know. I found a
dot.net request ID in
https://docs.microsoft.com/de-de/dotnet/api/microsoft.web.administration.request.requestid?view=iis-dotnet
but no native one in
https://docs.microsoft.com/en-us/iis/web-dev-reference/server-variables
Of course copying in one from a header with configured header name would
always be possible (not implemented yet).
Best regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: Request-ID added to mod_jk log
Posted by Rainer Jung <ra...@kippdata.de>.
Hi all,
first a short reminder: I added logging of a request id to the mod_jk
log to ease correlation with other Apache logs, like the access log. It
was motivated by a discussion with Chris, although the end result wasn't
exactly what he liked most.
After thinking more about the feature I changed the implementation. I'm
curious, whether it works for others as well.
I tested it with Apache on Linux and with IIS.
For Apache by default it uses the ID generated by mod_unique_id (needs
to be loaded). If that is loaded, Apache itself automatically uses that
id in its error logs as well and one can add it to the access log, eg.
via %{UNIQUE_ID}e.
One can also retrieve the request id from a custom env var configured
via JkRequestIdIndicator. For example assume a request id is received
via the HTTP header "X-REQUEST-ID-HEADER". Then you can configure:
JkRequestIdIndicator REQUEST-ID
and to copy the header value to this env var:
SetEnvIf X-REQUEST-ID-HEADER "(.+)" REQUEST-ID=$1
A small fix I still need to apply is falling back to the unique_id if
another request id is configured but not provided for a request.
For IIS the default ID is a generated GUID. I currently know of no way
how to log this in the IIS log files, but I didn't actually think long
about it.
You can also get an id via a request header that you configure with
"request_id_header".
You might want to experiment with it.
Probably we could release a 1.2.49 with it. Last release was more than a
year ago. No hurry though.
Best regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org