public class UsageLog extends Object
Uses the SLF4J MDC framework (see @link{org.slf4j.MDC} for more details).
If properly configured, each log entry within the context thread will include the gathered context information. For instance, in log4j and slf4j, the appender pattern would contain strings with the form "%X{<contextKey>}", where "<contextKey>" is a context key value. The context key strings are given in each setup method below.
MDC| Constructor and Description |
|---|
UsageLog() |
| Modifier and Type | Method and Description |
|---|---|
static String |
closingMessageForRequestContext(int resCode,
long resSizeInBytes)
Return a log message appropriate for logging at the completion of
the contexts HTTP request.
|
static String |
closingMessageNonRequestContext()
Return a log message appropriate for logging at the close of
the non-request context.
|
static String |
setupNonRequestContext()
Gather context information for the current non-request thread and
return a log message appropriate for logging.
|
static String |
setupRequestContext(javax.servlet.http.HttpServletRequest req)
Gather context information for the given HTTP request and return
a log message appropriate for logging at the start of the request.
|
public static String setupRequestContext(javax.servlet.http.HttpServletRequest req)
The following context information is gathered:
Call this method at the start of each HttpServlet doXXX() method (e.g., doGet(), doPut()) or Spring MVC Controller handle() method.
req - the current requestpublic static String closingMessageForRequestContext(int resCode, long resSizeInBytes)
Call this method at every exit point in each HttpServlet doXXX() method (e.g., doGet(), doPut()) or Spring MVC Controller handle() method.
resCode - - the result code for this request.resSizeInBytes - - the number of bytes returned in this result, -1 if unknown.public static String setupNonRequestContext()
The following context information is gathered:
Call this method only for non-request servlet activities, e.g., during init() or destroy().
public static String closingMessageNonRequestContext()
Copyright © 1999–2013 UCAR/Unidata. All rights reserved.