Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomRequestLog is missing HTTP version format option #6330

Closed
joakime opened this issue May 27, 2021 · 5 comments · Fixed by #6358, #6361 or #6362
Closed

CustomRequestLog is missing HTTP version format option #6330

joakime opened this issue May 27, 2021 · 5 comments · Fixed by #6358, #6361 or #6362
Assignees

Comments

@joakime
Copy link
Contributor

joakime commented May 27, 2021

Jetty version
9.4.x

Description
If someone wants to move away from CustomRequestLog NCSA format to one that is slightly tweaked but still includes HTTP version (as seen in the NCSA format), then they have to drop the HTTP version portion.

To explain, this started with the stackoverflow question at https://stackoverflow.com/questions/67635098/request-param-is-logged-in-access-log-with-embedded-jetty-server-of-spring-boot

They were using the old-school extended NCSA requestlog and format.
Which outputted the first line in the request POST /myAPI/v2/customer/message?myID=123&messageText=hello HTTP/1.0, but they wanted to strip away the query string.

The default format for Extended NCSA in CustomRequestLog is %{client}a - %u %t "%r" %s %O "%{Referer}i" "%{User-Agent}i", of which the "%r" portion logs the first line of the request, if they wanted to simulate the Extended NCSA format, but without the query string, they cannot, as HTTP Version is not an available format option, the best they can do is "%m %U" without the HTTP Version portion.

@lachlan-roberts
Copy link
Contributor

@joakime I think %H should do what you are looking for.
So you should replace the "%r" portion with "%m %U %H".

@joakime
Copy link
Contributor Author

joakime commented May 28, 2021

@lachlan-roberts I think you are correct.
Consider this a documentation issue then, we need to probably provide more explanation of that %H format option.

Perhaps even documentation on the %r option to show the equivalent in other options for the same output?

@lachlan-roberts
Copy link
Contributor

Perhaps even documentation on the %r option to show the equivalent in other options for the same output?

I don't think its possible to reproduce %r exactly with another format string. There is no percent code for request.getOriginalURI() so it is currently not possible.

@joakime
Copy link
Contributor Author

joakime commented May 28, 2021

Couldn't you use %m %U%q %H to be the equivalent of %r?

@lachlan-roberts
Copy link
Contributor

You could almost do it with %m %U%q %H but then you won't have the fragment string and it doesn't look like there is a percent code for that.
And also getOriginalURI() says it is before customization/rewrite.

lachlan-roberts added a commit that referenced this issue Jun 4, 2021
sbordet pushed a commit that referenced this issue Jun 4, 2021
@sbordet sbordet linked a pull request Jun 4, 2021 that will close this issue
sbordet added a commit that referenced this issue Jun 4, 2021
Improved javadocs for %H.

Signed-off-by: Simone Bordet <[email protected]>
sbordet added a commit that referenced this issue Jun 4, 2021
sbordet added a commit that referenced this issue Jun 4, 2021
sbordet added a commit that referenced this issue Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment