I am going through the post jetty logging and trying to figure out what is meaning of every attribute that prints
123.4.5.6 - - [27/Aug/2004:10:16:17 +0000] "GET /jetty/tut/XmlConfiguration.html HTTP/1.1" 200 76793 "http://localhost:8080/jetty/tut/logging.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040614 Firefox/0.8"
I am got the answers for some but still not able to figure out for some as mentioned below.
- 123.4.5.6 : request.getRemoteAddr()
- dash(-) : not able to figure out
- dash(-) : not able to figure out
- [27/Aug/2004:10:16:17 +0000] : timestamp
- GET : request.getMethod()
- jetty/tut/XmlConfiguration.html : request.getRequestURI()
- HTTP/1.1 : request.getProtocol()
- 200 : response.getStatus()
- 76793 : response.getHttpChannel().getBytesWritten()
- http://localhost:8080/jetty/tut/logging.html : not able to figure out
- Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040614 Firefox/0.8 : request.getHeader("User-Agent")
Please correct me if I am wrong for other attributes as well.
Recent versions of Jetty log requests with the
CustomRequestLogformat.Which has 2 default "NCSA" formats for output (along with a few others and the ability to customize the format)
NCSA_FORMAT- syntax declaration of"%{client}a - %u %t \"%r\" %s %O"EXTENDED_NCSA_FORMAT- syntax ofNCSA_FORMAT+" \"%{Referer}i\" \"%{User-Agent}i\""So, according to the documentation on
CustomRequestLog, that means that the following output ...is actually one of the extended NCSA formats.
Broken down like this ...
123.4.5.6: the%{client}awhich is therequest.getRemoteHost()-: the-a hardcoded string of-in Jetty, that entry would have been the "remote log name user", but since Jetty doesn't support identd, we don't have a means to fill this value out (identd is old school tech that never saw a big adoption for http)-: the%uwhich is the authenticated user name, which comes from Jetty internal APIs (eg:Request.getAuthentication()orAuthentication.getUserIdentity()- this only works if your webapp is using Servlet security / authentication / authorization - custom authentication techniques will not have this entry filled out.[27/Aug/2004:10:16:17 +0000]: the%twhich is the Jetty APIRequest.getTimeStamp()which is set in stone when the request was finished being parsed, but before its dispatched to a handler or webapp for processing."GET /jetty/tut/XmlConfiguration.html HTTP/1.1": the\"%r\"which is the raw "Request Line" used in HTTP. Which is the first line of the HTTP request. (orrequest.getMethod()+request.getOriginalURI()+request.getProtocol())200: the%swhich is the status as committed on the response obtained from the Jetty internal APIresponse.getCommittedMetadata().getStatus()(this API exists because theHttpServletResponseis mutable, and many webapps tend to modify it after it's been sent which would mean we log a value that wasn't actually sent if we used the standard servlet API here)76793: the%Owhich is the bytes sent on the network as part of the response which comes from the Jetty internal APIsresponse.getHttpChannel().getBytesWritten()"http://localhost:8080/jetty/tut/logging.html": the\"%{Referer}i\"which is requestRefererline (yes, it's spelled incorrectly, but there's ancient HTTP history here for why that's the case). It comes fromrequest.getHeader("Referer"), which can be empty in many cases."Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040614 Firefox/0.8": the\"%{User-Agent}i\"is the same as above, but for theUser-Agentrequest header.You can customize this output in countless ways, just read the
CustomRequestLogapidoc and create a format of your own that has what you want and/or what you are looking for.https://javadoc.io/doc/org.eclipse.jetty/jetty-server/latest/org.eclipse.jetty.server/org/eclipse/jetty/server/CustomRequestLog.html