public class HttpLoggingUtilities extends Object
| Constructor and Description |
|---|
HttpLoggingUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addRequestClientInfoToMDC(javax.servlet.http.HttpServletRequest request)
Puts http request infos (client infos) to MDC logging context.
|
protected static String |
anonymizeIp(String ip) |
protected static boolean |
isValidPublicIp(String ip)
From http://codereview.stackexchange.com/a/65072
|
protected static boolean isValidPublicIp(String ip)
ip - IP to checkpublic static void addRequestClientInfoToMDC(javax.servlet.http.HttpServletRequest request)
Usage example:
HttpLoggingUtilities.addRequestClientInfoToMDC(request);
MDC.put("collection name", name);
try {
Collection collection = presentationService.getCollection(name);
LOGGER.info("Serving collection for {}", name);
return collection;
} catch (NotFoundException e) {
LOGGER.info("Did not find collection for {}", name);
throw e;
} catch (InvalidDataException e) {
LOGGER.info("Bad data for {}", name);
throw e;
} finally {
MDC.clear();
}
request - http request object containing infoCopyright © 2018. All rights reserved.