public class LoggingInterceptor extends InterceptorAdapter
The following substitution variables are supported:
| ${id} | The resource ID associated with this request (or "" if none) |
| ${idOrResourceName} | The resource ID associated with this request, or the resource name if the request applies to a type but not an instance, or "" otherwise |
| ${operationName} | If the request is an extended operation (e.g. "$validate") this value will be the operation name, or "" otherwise |
| ${operationType} | A code indicating the operation type for this request, e.g. "read", "history-instance", "extended-operation-instance", etc.) |
| ${remoteAddr} | The originating IP of the request |
| ${requestHeader.XXXX} | The value of the HTTP request header named XXXX. For example, a substitution variable named "${requestHeader.x-forwarded-for} will yield the value of the first header named "x-forwarded-for ", or "" if none. |
| ${requestParameters} | The HTTP request parameters (or "") |
| ${responseEncodingNoDefault} | The encoding format requested by the client via the _format parameter or the Accept header. Value will be "json" or "xml", or "" if the client did not explicitly request a format |
| ${servletPath} | The part of thre requesting URL that corresponds to the particular Servlet being called (see
HttpServletRequest.getServletPath()) |
| ${requestBodyFhir} | The complete body of the request if the request has a FHIR content-type (this can be quite large!). Will emit an empty string if the content type is not a FHIR content type |
| ${requestUrl} | The complete URL of the request |
| ${requestVerb} | The HTTP verb of the request |
| ${exceptionMessage} | Applies only to an error message: The message from Throwable.getMessage() |
IServerInterceptor.ActionRequestDetails| Constructor and Description |
|---|
LoggingInterceptor()
Constructor for server logging interceptor
|
| Modifier and Type | Method and Description |
|---|---|
String |
getErrorMessageFormat()
Get the log message format to be used when logging exceptions
|
boolean |
handleException(RequestDetails theRequestDetails,
BaseServerResponseException theException,
javax.servlet.http.HttpServletRequest theServletRequest,
javax.servlet.http.HttpServletResponse theServletResponse)
This method is called upon any exception being thrown within the server's request processing code.
|
boolean |
isLogExceptions()
Should exceptions be logged by this logger
|
void |
processingCompletedNormally(ServletRequestDetails theRequestDetails)
This method is called after all processing is completed for a request, but only if the
request completes normally (i.e.
|
void |
setErrorMessageFormat(String theErrorMessageFormat)
Set the log message format to be used when logging exceptions
|
void |
setLogExceptions(boolean theLogExceptions)
Should exceptions be logged by this logger
|
void |
setLogger(org.slf4j.Logger theLogger) |
void |
setLoggerName(String theLoggerName) |
void |
setMessageFormat(String theMessageFormat)
Sets the message format itself.
|
incomingRequestPostProcessed, incomingRequestPreHandled, incomingRequestPreProcessed, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, outgoingResponse, preProcessOutgoingExceptionpublic LoggingInterceptor()
public String getErrorMessageFormat()
public boolean handleException(RequestDetails theRequestDetails, BaseServerResponseException theException, javax.servlet.http.HttpServletRequest theServletRequest, javax.servlet.http.HttpServletResponse theServletResponse) throws javax.servlet.ServletException, IOException
IServerInterceptorSearch and Read methods) as well as
any runtime exceptions thrown by the server itself. This also includes any AuthenticationExceptions
thrown.
Implementations of this method may choose to ignore/log/count/etc exceptions, and return true. In
this case, processing will continue, and the server will automatically generate an OperationOutcome. Implementations may also choose to provide their own response to the client. In this case, they
should return false, to indicate that they have handled the request and processing should stop.
handleException in interface IServerInterceptorhandleException in class InterceptorAdaptertheRequestDetails - A bean containing details about the request that is about to be processed, including details such as the
resource type and logical ID (if any) and other FHIR-specific aspects of the request which have been
pulled out of the servlet request. Note that the bean
properties are not all guaranteed to be populated, depending on how early during processing the
exception occurred.theServletRequest - The incoming requesttheServletResponse - The response. Note that interceptors may choose to provide a response (i.e. by calling
ServletResponse.getWriter()) but in that case it is important to return
false to indicate that the server itself should not also provide a response.true if processing should continue normally. This is generally the right thing to do.
If your interceptor is providing a response rather than letting HAPI handle the response normally, you
must return false. In this case, no further processing will occur and no further interceptors
will be called.javax.servlet.ServletException - If this exception is thrown, it will be re-thrown up to the container for handling.IOException - If this exception is thrown, it will be re-thrown up to the container for handling.public void processingCompletedNormally(ServletRequestDetails theRequestDetails)
IServerInterceptorNote that this individual interceptors will have this method called in the reverse order from the order in which the interceptors were registered with the server.
processingCompletedNormally in interface IServerInterceptorprocessingCompletedNormally in class InterceptorAdaptertheRequestDetails - The request itselfpublic boolean isLogExceptions()
public void setErrorMessageFormat(String theErrorMessageFormat)
public void setLogExceptions(boolean theLogExceptions)
public void setLogger(org.slf4j.Logger theLogger)
public void setLoggerName(String theLoggerName)
public void setMessageFormat(String theMessageFormat)
class documentation for information on the
formatCopyright © 2014–2017 University Health Network. All rights reserved.