Skip to content

CustomRequestLog is missing HTTP version format option #6330

Closed
@joakime

Description

@joakime
Contributor

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.

Activity

lachlan-roberts

lachlan-roberts commented on May 28, 2021

@lachlan-roberts
Contributor

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

joakime

joakime commented on May 28, 2021

@joakime
ContributorAuthor

@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

lachlan-roberts commented on May 28, 2021

@lachlan-roberts
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

joakime commented on May 28, 2021

@joakime
ContributorAuthor

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

lachlan-roberts

lachlan-roberts commented on May 28, 2021

@lachlan-roberts
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.

added a commit that references this issue on Jun 4, 2021

Issue #6330 - Improve javadoc for CustomRequestLog %H

added a commit that references this issue on Jun 4, 2021

Issue #6330 - Improve javadoc for CustomRequestLog %H

added 2 commits that reference this issue on Jun 4, 2021

Fixes #6330 - CustomRequestLog is missing HTTP version format option.

b83941c

Fixes #6330 - CustomRequestLog is missing HTTP version format option. (

9b6b956
added a commit that references this issue on Jun 4, 2021

Fixes #6330 - CustomRequestLog is missing HTTP version format option.

f41c579
added a commit that references this issue on Jun 4, 2021

Fixes #6330 - CustomRequestLog is missing HTTP version format option. (

3a8af44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @joakime@lachlan-roberts

    Issue actions

      CustomRequestLog is missing HTTP version format option · Issue #6330 · jetty/jetty.project