tds/src/main/java/thredds/servlet/UsageLog.java
public static String setupRequestContext(HttpServletRequest req) {

    // Setup context.
    //HttpSession session = req.getSession(false);
    /* MDC.put("host", req.getRemoteHost());
    MDC.put("ident", (session == null) ? "-" : session.getId());
    MDC.put("userid", req.getRemoteUser() != null ? req.getRemoteUser() : "-"); */

    MDC.put("ID", Long.toString(logServerAccessId.incrementAndGet()));
    MDC.put("startTime", Long.toString(System.currentTimeMillis()));

    String query = req.getQueryString();
    query = (query != null) ? "?" + query : "";
    Formatter request = new Formatter();
    request.format("\"%s %s%s %s\"", req.getMethod(), req.getRequestURI(), query, req.getProtocol());

    MDC.put("request", request.toString());
    return "Remote host: " + req.getRemoteHost() + " - Request: " + request.toString();
  }
public static String setupRequestContext(HttpServletRequest req) {

    // Setup context.
    //HttpSession session = req.getSession(false);
    /* MDC.put("host", req.getRemoteHost());
    MDC.put("ident", (session == null) ? "-" : session.getId());
    MDC.put("userid", req.getRemoteUser() != null ? req.getRemoteUser() : "-"); */

    MDC.put("ID", Long.toString(logServerAccessId.incrementAndGet()));
    MDC.put("startTime", Long.toString(System.currentTimeMillis()));

    String query = req.getQueryString();
    query = (query != null) ? "?" + query : "";
    Formatter request = new Formatter();
    request.format("\"%s %s%s %s\"", req.getMethod(), req.getRequestURI(), query, req.getProtocol());

    MDC.put("request", request.toString());
    return "Remote host: " + req.getRemoteHost() + " - Request: " + request.toString();
  }
Gather context information for the given HTTP request and return
a log message appropriate for logging at the start of the request.
<p/>
<p>The following context information is gathered:
<ul>
<li>"ID" - an identifier for the current thread;</li>
<li>"host" - the remote host (IP address or host name);</li>
<li>"userid" - the id of the remote user;</li>
<li>"startTime" - the system time in millis when this request is started (i.e., when this method is called); and</li>
<li>"request" - The HTTP request, e.g., "GET /index.html HTTP/1.1".</li>
</ul>
<p/>
<p>Call this method at the start of each HttpServlet doXXX() method
(e.g., doGet(), doPut()) or Spring MVC Controller handle() method.

@param req the current request
@return a log message appropriate for the start of the request.