Package org.hawaiiframework.logging.util
Class HttpRequestResponseLogUtil
- java.lang.Object
-
- org.hawaiiframework.logging.util.HttpRequestResponseLogUtil
-
public class HttpRequestResponseLogUtil extends Object
Utility for logging requests / responses.The utility can be used to generate HTTP request / response log strings. Both for incoming service calls as outgoing calls (i.e. calls to backend systems).
- Since:
- 2.0.0
- Author:
- Rutger Lubbers
-
-
Constructor Summary
Constructors Constructor Description HttpRequestResponseLogUtil()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
createLogString(String requestLine, org.springframework.http.HttpHeaders headers, byte[] body, String characterEncoding)
Create a log string for the givenrequestLine
,headers
andbody
.String
createLogString(String requestLine, org.springframework.http.HttpHeaders headers, byte[] body, Charset charset)
Create a log string for the givenrequestLine
,headers
andbody
.String
createLogString(String requestLine, org.springframework.http.HttpHeaders headers, String body)
Create a log string for the givenrequestLine
,headers
andbody
.String
createLogString(org.springframework.http.HttpHeaders headers, byte[] body)
Create a log string for the givenheaders
andbody
with the platform's default charset.String
createLogString(org.springframework.http.HttpHeaders headers, byte[] body, String characterEncoding)
Create a log string for the givenheaders
andbody
with the givencharacterEncoding
.String
createLogString(org.springframework.http.HttpHeaders headers, byte[] body, Charset charset)
Create a log string for the givenheaders
andbody
with the givencharset
.String
createLogString(org.springframework.http.HttpHeaders headers, String body)
Create a log string for the givenheaders
andbody
with the platform's default charset.String
createRequestLine(String request, String protocol)
Create a request line for therequestUri
andprotocol
.String
formatRequest(String request, javax.servlet.http.HttpServletRequest servletRequest)
Format the request as a nicely formatted string.org.springframework.http.HttpHeaders
getHeaders(javax.servlet.http.HttpServletRequest request)
CreateHttpHeaders
for therequest
.org.springframework.http.HttpHeaders
getHeaders(javax.servlet.http.HttpServletResponse response)
CreateHttpHeaders
for theresponse
.String
getRequestUri(javax.servlet.http.HttpServletRequest servletRequest)
Transform the request into a log line.
-
-
-
Method Detail
-
getHeaders
public org.springframework.http.HttpHeaders getHeaders(javax.servlet.http.HttpServletRequest request)
CreateHttpHeaders
for therequest
.
-
getHeaders
public org.springframework.http.HttpHeaders getHeaders(javax.servlet.http.HttpServletResponse response)
CreateHttpHeaders
for theresponse
.
-
createRequestLine
public String createRequestLine(String request, String protocol)
Create a request line for therequestUri
andprotocol
.For example:
GET /doc/test.html HTTP/1.1
.
-
createLogString
public String createLogString(org.springframework.http.HttpHeaders headers, String body)
Create a log string for the givenheaders
andbody
with the platform's default charset.
-
createLogString
public String createLogString(org.springframework.http.HttpHeaders headers, byte[] body)
Create a log string for the givenheaders
andbody
with the platform's default charset.
-
createLogString
public String createLogString(org.springframework.http.HttpHeaders headers, byte[] body, String characterEncoding)
Create a log string for the givenheaders
andbody
with the givencharacterEncoding
.
-
createLogString
public String createLogString(org.springframework.http.HttpHeaders headers, byte[] body, Charset charset)
Create a log string for the givenheaders
andbody
with the givencharset
.
-
createLogString
public String createLogString(String requestLine, org.springframework.http.HttpHeaders headers, byte[] body, String characterEncoding)
Create a log string for the givenrequestLine
,headers
andbody
.
-
createLogString
public String createLogString(String requestLine, org.springframework.http.HttpHeaders headers, byte[] body, Charset charset)
Create a log string for the givenrequestLine
,headers
andbody
.
-
createLogString
public String createLogString(String requestLine, org.springframework.http.HttpHeaders headers, String body)
Create a log string for the givenrequestLine
,headers
andbody
.
-
getRequestUri
public String getRequestUri(javax.servlet.http.HttpServletRequest servletRequest)
Transform the request into a log line.
-
formatRequest
public String formatRequest(String request, javax.servlet.http.HttpServletRequest servletRequest) throws IOException
Format the request as a nicely formatted string.Note that this will read the request! Use
ResettableHttpServletRequest
for instance to reset the input.- Throws:
IOException
-
-