From 5dcba2269e3a9a0be39f0093194ddeb0c70c20aa Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 19 Dec 2017 12:30:19 -0500 Subject: Fix logging filters Update logging filters package to handle X-Forwarded-For header and to correct timestamp format. Change-Id: I6b4dba94cc93d0936598a9b8cd568b6386a447a5 Issue-ID: CCSDK-155 Signed-off-by: Dan Timoney --- .../src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'filters') diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java index abbb7c66e..d7a599cb3 100644 --- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java +++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java @@ -194,7 +194,13 @@ public class LogFilter implements Filter { //MDC.put(SERVER_IP,""); //by chef MDC.put(ELAPSED_TIME,Long.toString(System.currentTimeMillis() - startTime)); //MDC.put(SERVER_HOST,""); //by chef + String forwardedHost = request.getHeader("X-Forwarded-For"); + if (forwardedHost != null) { + MDC.put(CLIENT_IP, forwardedHost); + } + else{ MDC.put(CLIENT_IP,request.getRemoteHost()); + } MDC.put(CLASS,""); MDC.put(UNUSED,""); MDC.put(PROCESS_KEY,""); @@ -209,7 +215,7 @@ public class LogFilter implements Filter { private String asIso8601(Date date) { TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'hh:mm:ss:SS'+00:00'"); + DateFormat df = new SimpleDateFormat("yyy-MM-dd'T'HH:mm:ss.SS'+00:00'"); df.setTimeZone(tz); return df.format(date); } -- cgit 1.2.3-korg