aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-02-06 17:51:41 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-02-06 17:51:41 +0100
commit23001a5e8d48d8ab15309613fd0bfd30f5aeff96 (patch)
tree2bdec043e1b5762c77f2184f59a1c794e8058917 /src
parent70094ae98a374550b8fd4686cf58f7f629c062f2 (diff)
Improve Log Util class.
Improve Log Util class to support RequestContext Issue-ID: CLAMP-85 Change-Id: Ied88b3824014592a8748aba80d429dab7ecdc670 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/clamp/clds/util/LoggingUtils.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
index bca413415..f14d71f6a 100644
--- a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
+++ b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,6 +23,8 @@
package org.onap.clamp.clds.util;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -31,11 +33,16 @@ import java.util.UUID;
import javax.validation.constraints.NotNull;
import org.apache.log4j.MDC;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
/**
* This class handles the special info that appear in the log, like RequestID,
* time context, ...
*/
public final class LoggingUtils {
+
+ protected static final EELFLogger logger = EELFManager.getInstance().getLogger(LoggingUtils.class);
private static final DateFormat DATE_FORMAT = createDateFormat();
@@ -55,6 +62,12 @@ public final class LoggingUtils {
MDC.put("RequestId", UUID.randomUUID().toString());
MDC.put("ServiceName", service);
MDC.put("PartnerName", partner);
+ try {
+ MDC.put("ServerFQDN", InetAddress.getLocalHost().getCanonicalHostName());
+ MDC.put("ServerIPAddress", InetAddress.getLocalHost().getHostAddress());
+ } catch (UnknownHostException e) {
+ logger.error("Failed to initiate setRequestContext", e);
+ }
}
/**