Class HttpLoggingUtilities
- java.lang.Object
-
- de.digitalcollections.commons.server.HttpLoggingUtilities
-
public class HttpLoggingUtilities extends Object
-
-
Constructor Summary
Constructors Constructor Description HttpLoggingUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddRequestClientInfoToMDC(javax.servlet.http.HttpServletRequest request)Puts http request infos (client infos) to MDC logging context.protected static StringanonymizeIp(String ip)protected static booleanisValidPublicIp(String ip)From http://codereview.stackexchange.com/a/65072
-
-
-
Method Detail
-
isValidPublicIp
protected static boolean isValidPublicIp(String ip)
From http://codereview.stackexchange.com/a/65072- Parameters:
ip- IP to check- Returns:
- true if IP is a valid public IP
-
addRequestClientInfoToMDC
public static void addRequestClientInfoToMDC(javax.servlet.http.HttpServletRequest request)
Puts http request infos (client infos) to MDC logging context. Make sure to clear MDC after logging! Using MDC instead of LogstashMarker, because otherwise we drag in logging implementation logstash as dependency. We care for having no other logging dependency than slf4j.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(); }- Parameters:
request- http request object containing info
-
-