diff options
author | 2017-12-19 12:30:19 -0500 | |
---|---|---|
committer | 2017-12-19 12:30:19 -0500 | |
commit | 5dcba2269e3a9a0be39f0093194ddeb0c70c20aa (patch) | |
tree | fd0ec9b41d7cd2bf6d8d9b2cbff70b8b9d0844c4 /filters/provider/src/main/java | |
parent | 8baaa038d6465a94aef0baf6b1cddca414a5505a (diff) |
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 <dtimoney@att.com>
Diffstat (limited to 'filters/provider/src/main/java')
-rw-r--r-- | filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/LogFilter.java | 8 |
1 files changed, 7 insertions, 1 deletions
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); } |