Logging Library 63/5963/1
authorSumit Kaushik <sk00613223@TechMahindra.com>
Fri, 22 Nov 2019 16:09:25 +0000 (21:39 +0530)
committerSumit Kaushik <sk00613223@TechMahindra.com>
Fri, 22 Nov 2019 16:11:45 +0000 (21:41 +0530)
ISSUE-ID : ACUMOS-3632

Logging Library Implementation

Change-Id: I5754f14469738c88599fa05f6e0e97a9095d1d2f
Signed-off-by: Sumit Kaushik <sk00613223@TechMahindra.com>
logging-demo/pom.xml
logging-demo/src/main/java/org/acumos/demo/logging/Application.java [deleted file]
logging-demo/src/main/java/org/acumos/demo/logging/Execute.java [deleted file]
logging-demo/src/main/java/org/acumos/demo/logging/LoggingTaskDecorator.java [deleted file]
logging-demo/src/main/java/org/acumos/demo/logging/service/ApplicationService.java [deleted file]
logging-demo/src/main/java/org/acumos/demo/logging/util/ACUMOSLogConstants.java
logging-demo/src/main/java/org/acumos/demo/logging/util/LogConfig.java
logging-demo/src/main/java/org/acumos/demo/logging/util/LoggingConstant.java [new file with mode: 0644]
logging-demo/src/test/java/com/example/demo/DemoApplicationTests.java [deleted file]

index 4a1f6f7..a0769b6 100644 (file)
@@ -23,7 +23,7 @@
 
        <groupId>org.acumos.platform-oam</groupId>
        <artifactId>logging-demo</artifactId>
-       <version>2.0.8-SNAPSHOT</version>
+       <version>3.0.4-SNAPSHOT</version>
        <packaging>jar</packaging>
        <name>logging-demo</name>
        <description>Demo project for Logging</description>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                <java.version>1.8</java.version>
+               <springfox.version>2.6.1</springfox.version>
        </properties>
 
        <dependencies>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-web</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.springframework.boot</groupId>
-                       <artifactId>spring-boot-starter-test</artifactId>
-                       <scope>test</scope>
-               </dependency>
                <dependency>
                        <groupId>org.apache.commons</groupId>
                        <artifactId>commons-lang3</artifactId>
                        <artifactId>logback-core</artifactId>
                </dependency>
        </dependencies>
-
-       <build>
-               <plugins>
-                       <plugin>
-                               <groupId>org.springframework.boot</groupId>
-                               <artifactId>spring-boot-maven-plugin</artifactId>
-                       </plugin>
-               </plugins>
-       </build>
-
-
 </project>
+       
\ No newline at end of file
diff --git a/logging-demo/src/main/java/org/acumos/demo/logging/Application.java b/logging-demo/src/main/java/org/acumos/demo/logging/Application.java
deleted file mode 100644 (file)
index 94bca41..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  ===============LICENSE_START=======================================================
-  Acumos
-  ===================================================================================
-  Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
-  ===================================================================================
-  This Acumos software file is distributed by AT&T and Tech Mahindra
-  under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-   
-          http://www.apache.org/licenses/LICENSE-2.0
-   
-  This file is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ===============LICENSE_END=========================================================
-  */
-package org.acumos.demo.logging;
-
-import java.util.concurrent.Executor;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Bean;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-@SpringBootApplication
-@EnableAsync
-public class Application {
-
-       @Bean
-       public Executor asyncExecutor() {
-               ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-               executor.setTaskDecorator(new LoggingTaskDecorator());
-               executor.initialize();
-               return executor;
-       }
-
-       public static void main(String[] args) {
-               SpringApplication.run(Application.class, args);
-       }
-}
diff --git a/logging-demo/src/main/java/org/acumos/demo/logging/Execute.java b/logging-demo/src/main/java/org/acumos/demo/logging/Execute.java
deleted file mode 100644 (file)
index ccf614c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-  ===============LICENSE_START=======================================================
-  Acumos
-  ===================================================================================
-  Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
-  ===================================================================================
-  This Acumos software file is distributed by AT&T and Tech Mahindra
-  under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-   
-          http://www.apache.org/licenses/LICENSE-2.0
-   
-  This file is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ===============LICENSE_END=========================================================
-  */
-package org.acumos.demo.logging;
-
-import java.util.UUID;
-import org.acumos.demo.logging.service.ApplicationService;
-import org.acumos.demo.logging.util.ACUMOSLogConstants;
-import org.acumos.demo.logging.util.ACUMOSLogConstants.MDCs;
-import org.slf4j.MDC;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.stereotype.Component;
-
-@Component
-public class Execute implements CommandLineRunner {
-       private ApplicationService applicationService;
-
-       public Execute(ApplicationService applicationService) {
-               this.applicationService = applicationService;
-       }
-
-       @Override
-       public void run(String... args) {
-
-               String txId = UUID.randomUUID().toString();
-               ACUMOSLogConstants.setDefaultMDCs();
-               MDC.put(MDCs.REQUEST_ID, txId);         
-               MDC.put(MDCs.TARGET_ENTITY, "Onboarding");
-               MDC.put(MDCs.TARGET_SERVICE_NAME, "Onboarding/api/v2");
-               MDC.put(MDCs.CLIENT_IP_ADDRESS, "127.0.0.1");
-               MDC.put(MDCs.SERVER_FQDN, "put.your.host.name.here");
-
-               applicationService.logNormalThread();
-               applicationService.logAsyncThread();
-       }
-
-}
diff --git a/logging-demo/src/main/java/org/acumos/demo/logging/LoggingTaskDecorator.java b/logging-demo/src/main/java/org/acumos/demo/logging/LoggingTaskDecorator.java
deleted file mode 100644 (file)
index 43f9b57..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-  ===============LICENSE_START=======================================================
-  Acumos
-  ===================================================================================
-  Copyright (C) 2019 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
-  ===================================================================================
-  This Acumos software file is distributed by AT&T and Tech Mahindra
-  under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-   
-          http://www.apache.org/licenses/LICENSE-2.0
-   
-  This file is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ===============LICENSE_END=========================================================
-  */
-package org.acumos.demo.logging;
-
-import java.util.Map;
-
-import org.slf4j.MDC;
-import org.springframework.core.task.TaskDecorator;
-
-/**
- * Copy MDC data from a Web thread context onto the asynchronous threads’
- * context.
- *
- */
-public class LoggingTaskDecorator implements TaskDecorator {
-
-       @Override
-       public Runnable decorate(Runnable runnable) {
-               // Right now: Web thread context !
-               // (Grab the current thread MDC data)
-               Map<String, String> contextMap = MDC.getCopyOfContextMap();
-               return () -> {
-                       try {
-                               // Right now: @Async thread context !
-                               // (Restore the Web thread context's MDC data)
-                               MDC.setContextMap(contextMap);
-                               runnable.run();
-                       } finally {
-                               MDC.clear();
-                       }
-               };
-       }
-
-}
diff --git a/logging-demo/src/main/java/org/acumos/demo/logging/service/ApplicationService.java b/logging-demo/src/main/java/org/acumos/demo/logging/service/ApplicationService.java
deleted file mode 100644 (file)
index 2f45e33..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-  ===============LICENSE_START=======================================================
-  Acumos
-  ===================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
-  ===================================================================================
-  This Acumos software file is distributed by AT&T and Tech Mahindra
-  under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-   
-          http://www.apache.org/licenses/LICENSE-2.0
-   
-  This file is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ===============LICENSE_END=========================================================
-  */
-package org.acumos.demo.logging.service;
-
-import org.acumos.demo.logging.util.ACUMOSLogConstants.InvocationMode;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-
-@Service
-public class ApplicationService {
-       private static final Logger log = LoggerFactory.getLogger(ApplicationService.class);
-       
-
-    public void logNormalThread() {
-    
-       log.info(InvocationMode.SYNCHRONOUS.getMarker(),"platform-oam");
-    
-    }
-
-    @Async
-    public void logAsyncThread() {
-    
-       log.info(InvocationMode.ASYNCHRONOUS.getMarker(),"platform-oam");
-        
-    }
-
-}
index cefe063..f6876df 100644 (file)
@@ -21,19 +21,23 @@ package org.acumos.demo.logging.util;
 
 import org.slf4j.Marker;
 import org.slf4j.MarkerFactory;
-import org.slf4j.MDC;
 
+import java.util.Properties;
+
+import org.slf4j.MDC;
 
 /**
  * Constants for standard ACUMOS headers, MDCs, etc.
  *
  */
-public  class ACUMOSLogConstants {
+public class ACUMOSLogConstants {
 
        /**
         * Hide and forbid construction.
         */
+
        private ACUMOSLogConstants() {
+
                throw new UnsupportedOperationException();
        }
 
@@ -46,28 +50,26 @@ public  class ACUMOSLogConstants {
        /**
         * Marker constants.
         */
-       public static  class Markers {
+       public static class Markers {
 
                /** Marker reporting invocation. */
-               public static  Marker INVOKE = MarkerFactory.getMarker("INVOKE");
-
-               
+               public static Marker INVOKE = MarkerFactory.getMarker(LoggingConstant.INVOKE);
 
                /** Marker reporting invocation. */
-               public static  Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE_RETURN");
+               public static Marker INVOKE_RETURN = MarkerFactory.getMarker(LoggingConstant.INVOKE_RETURN);
 
                /** Marker reporting synchronous invocation. */
-               public static  Marker INVOKE_SYNCHRONOUS = build("INVOKE", "SYNCHRONOUS");
+               public static Marker INVOKE_SYNCHRONOUS = build(LoggingConstant.INVOKE, LoggingConstant.SYNCHRONOUS);
 
                /** Marker reporting asynchronous invocation. */
-               public static  Marker INVOKE_ASYNCHRONOUS = build("INVOKE", "ASYNCHRONOUS");
+               public static Marker INVOKE_ASYNCHRONOUS = build(LoggingConstant.INVOKE, LoggingConstant.ASYNCHRONOUS);
 
                /** Marker reporting entry into a component. */
-               public static  Marker ENTRY = MarkerFactory.getMarker("ENTRY");
+               public static Marker ENTRY = MarkerFactory.getMarker(LoggingConstant.ENTRY);
 
                /** Marker reporting exit from a component. */
-               public static  Marker EXIT = MarkerFactory.getMarker("EXIT");
-               
+               public static Marker EXIT = MarkerFactory.getMarker(LoggingConstant.EXIT);
+
                public static Marker getINVOKE() {
                        return INVOKE;
                }
@@ -125,8 +127,8 @@ public  class ACUMOSLogConstants {
                 *            sub-token.
                 * @return detached Marker.
                 */
-               private static Marker build( String m1,  String m2) {
-                        Marker marker = MarkerFactory.getDetachedMarker(m1);
+               private static Marker build(String m1, String m2) {
+                       Marker marker = MarkerFactory.getDetachedMarker(m1);
                        marker.add(MarkerFactory.getDetachedMarker(m2));
                        return marker;
                }
@@ -142,62 +144,60 @@ public  class ACUMOSLogConstants {
        /**
         * MDC name constants.
         */
-       public static  class MDCs {
-               
-               public enum ResponseStatus {
-                       
-                       COMPLETED,
-                       ERROR,
-                       INPROGRESS
-               }
-               
-               public enum ResponseSeverity {
+       public static class MDCs {
+
+               public enum ResponseStatusMDC {
+
+                       MDC_COMPLETED, MDC_ERROR, MDC_INPROGRESS;
+
+                       /** Enum value. */
 
-                       INFO,
-                       ERROR,
-                       TRACE,
-                       DEBUG,
-                       WARN,
-                       FATAL
                }
 
+               public enum ResponseSeverityMDC {
+
+                       
+                       /** Enum value. */
+
+                       MDC_INFO, MDC_ERROR, MDC_TRACE, MDC_DEBUG, MDC_WARN, MDC_FATAL;
+
+                       /** Enum value. */
+
+               }
 
                // Tracing. ////////////////////////////////////////////////////////////
 
                /** MDC correlating messages for a logical transaction. */
-               public static  String REQUEST_ID = "RequestID";
-
-               
+               public static String REQUEST_ID = LoggingConstant.REQUEST_ID;
 
                /** MDC recording target service. */
-               public static  String TARGET_SERVICE_NAME = "TargetServiceName";
+               public static String TARGET_SERVICE_NAME = LoggingConstant.TARGET_SERVICE_NAME;
 
                /** MDC recording target entity. */
-               public static  String TARGET_ENTITY = "TargetEntity";
+               public static String TARGET_ENTITY = LoggingConstant.TARGET_ENTITY;
 
                // Network. ////////////////////////////////////////////////////////////
 
                /** MDC recording caller address. */
-               public static  String CLIENT_IP_ADDRESS = "ClientIPAddress";
+               public static String CLIENT_IP_ADDRESS = LoggingConstant.CLIENT_IP_ADDRESS;
 
                /** MDC recording server address. */
-               public static  String SERVER_FQDN = "ServerFQDN";
+               public static String SERVER_FQDN = LoggingConstant.SERVER_FQDN;
 
                /** MDC reporting outcome code. */
-               public static  String RESPONSE_CODE = "ResponseCode";
+               public static String RESPONSE_CODE = LoggingConstant.RESPONSE_CODE;
 
                /** MDC reporting outcome description. */
-               public static  String RESPONSE_DESCRIPTION = "ResponseDescription";
+               public static String RESPONSE_DESCRIPTION = LoggingConstant.RESPONSE_DESCRIPTION;
 
                /** MDC reporting outcome error level. */
-               public static  String RESPONSE_SEVERITY = "Severity";
+               public static String RESPONSE_SEVERITY = LoggingConstant.RESPONSE_SEVERITY;
 
                /** MDC reporting outcome status of the request. */
-               public static  String STATUS_CODE = "StatusCode";
-               
-               public static  String USER = "User";
-               
-               
+               public static String STATUS_CODE = LoggingConstant.STATUS_CODE;
+
+               public static String USER = LoggingConstant.USER;
+
                public static String getUSER() {
                        return USER;
                }
@@ -277,8 +277,7 @@ public  class ACUMOSLogConstants {
                public static void setSTATUS_CODE(String sTATUS_CODE) {
                        STATUS_CODE = sTATUS_CODE;
                }
-               
-               
+
                // Unsorted. ///////////////////////////////////////////////////////////
 
                /**
@@ -292,10 +291,10 @@ public  class ACUMOSLogConstants {
        /**
         * Header name constants.
         */
-       public static  class Headers {
+       public static class Headers {
 
                /** HTTP X-ACUMOS-RequestID header. */
-               public static  String REQUEST_ID = "X-ACUMOS-RequestID";
+               public static String REQUEST_ID = "X-ACUMOS-RequestID";
 
                /**
                 * Hide and forbid construction.
@@ -323,10 +322,8 @@ public  class ACUMOSLogConstants {
         * Response success or not, for setting StatusCode.
         */
        public enum ResponseStatus {
-               
-               COMPLETED,
-               ERROR,
-               INPROGRESS
+
+               COMPLETED, ERROR, INPROGRESS
        }
 
        /**
@@ -334,12 +331,7 @@ public  class ACUMOSLogConstants {
         */
        public enum ResponseSeverity {
 
-               INFO,
-               ERROR,
-               TRACE,
-               DEBUG,
-               WARN,
-               FATAL
+               INFO, ERROR, TRACE, DEBUG, WARN, FATAL
        }
 
        /**
@@ -348,17 +340,17 @@ public  class ACUMOSLogConstants {
        public enum InvocationMode {
 
                /** Synchronous, blocking. */
-               SYNCHRONOUS("SYNCHRONOUS", Markers.INVOKE_SYNCHRONOUS),
+               SYNCHRONOUS(LoggingConstant.SYNCHRONOUS, Markers.INVOKE_SYNCHRONOUS),
 
                /** Asynchronous, non-blocking. */
-               ASYNCHRONOUS("ASYNCHRONOUS", Markers.INVOKE_ASYNCHRONOUS);
+               ASYNCHRONOUS(LoggingConstant.ASYNCHRONOUS, Markers.INVOKE_ASYNCHRONOUS);
 
                /** Enum value. */
                private String mString;
 
                /** Corresponding marker. */
                private Marker mMarker;
-               
+
                public String getmString() {
                        return mString;
                }
@@ -367,7 +359,7 @@ public  class ACUMOSLogConstants {
                        this.mString = mString;
                }
 
-               public Marker getMarker() {
+               public Marker getmMarker() {
                        return this.mMarker;
                }
 
@@ -383,7 +375,7 @@ public  class ACUMOSLogConstants {
                 * @param m
                 *            corresponding Marker.
                 */
-               InvocationMode( String s,  Marker m) {
+               InvocationMode(String s, Marker m) {
                        this.mString = s;
                        this.mMarker = m;
                }
@@ -393,7 +385,7 @@ public  class ACUMOSLogConstants {
                 *
                 * @return Marker.
                 */
-               
+
                @Override
                public String toString() {
                        return this.mString;
index 6b95a00..e5bbda8 100644 (file)
@@ -20,48 +20,82 @@ limitations under the License.
 package org.acumos.demo.logging.util;
 
 import java.net.InetAddress;
+import java.util.Properties;
 import java.util.UUID;
 
 import org.acumos.demo.logging.util.ACUMOSLogConstants.MDCs;
+import org.acumos.demo.logging.util.ACUMOSLogConstants.ResponseStatus;
 import org.slf4j.MDC;
 
 public class LogConfig {
-       public static void setEnteringMDCs(String targetEntry,String targetService,String user) throws Exception{
-               String hostname="";
-        String ip="";
+
+       public static void setEnteringMDCs(String targetEntry, String targetService, String user, String responseCode,
+                       String responseSeverity) throws Exception {
+               String hostname = "";
+               String ip = "";
+
                ACUMOSLogConstants.setDefaultMDCs();
                String requestId = UUID.randomUUID().toString();
-               String finalHostIP=getHostDetails();
-               if(finalHostIP!=null) {
-                       String hostIpArr[]=finalHostIP.split("/");
-                       hostname=hostIpArr[0];
-                       ip=hostIpArr[1];
+               String finalHostIP = getHostDetails();
+               if (finalHostIP != null) {
+                       String hostIpArr[] = finalHostIP.split("/");
+                       hostname = hostIpArr[0];
+                       ip = hostIpArr[1];
                }
-               MDC.put(MDCs.REQUEST_ID, requestId);            
+               MDC.put(MDCs.REQUEST_ID, requestId);
                MDC.put(MDCs.TARGET_ENTITY, targetEntry);
                MDC.put(MDCs.TARGET_SERVICE_NAME, targetService);
                MDC.put(MDCs.CLIENT_IP_ADDRESS, ip);
                MDC.put(MDCs.SERVER_FQDN, hostname);
-               MDC.put(MDCs.USER, user);
 
-               
+               if (user != null && !user.isEmpty()) {
+                       MDC.put(MDCs.USER, user);
+               }
+
+               if (responseCode != null && !responseCode.isEmpty()) {
+                       if (responseCode.equalsIgnoreCase(LoggingConstant.MDC_COMPLETED)) {
+                               MDC.put(MDCs.RESPONSE_DESCRIPTION, MDCs.ResponseStatusMDC.MDC_COMPLETED.toString());
+                       } else if (responseCode.equalsIgnoreCase(LoggingConstant.MDC_ERROR)) {
+                               MDC.put(MDCs.RESPONSE_DESCRIPTION, MDCs.ResponseStatusMDC.MDC_ERROR.toString());
+                       } else if (responseCode.equalsIgnoreCase(LoggingConstant.MDC_INPROGRESS)) {
+                               MDC.put(MDCs.RESPONSE_DESCRIPTION, MDCs.ResponseStatusMDC.MDC_INPROGRESS.toString());
+                       }
+               }
+
+               if (responseSeverity != null && !responseSeverity.isEmpty()) {
+                       if (responseSeverity.equalsIgnoreCase(LoggingConstant.MDC_INFO)) {
+                               MDC.put(MDCs.RESPONSE_SEVERITY, MDCs.ResponseSeverityMDC.MDC_INFO.toString());
+                       } else if (responseSeverity.equalsIgnoreCase(LoggingConstant.MDC_ERROR)) {
+                               MDC.put(MDCs.RESPONSE_SEVERITY, MDCs.ResponseSeverityMDC.MDC_ERROR.toString());
+                       } else if (responseSeverity.equalsIgnoreCase(LoggingConstant.MDC_TRACE)) {
+                               MDC.put(MDCs.RESPONSE_SEVERITY, MDCs.ResponseSeverityMDC.MDC_TRACE.toString());
+                       } else if (responseSeverity.equalsIgnoreCase(LoggingConstant.MDC_DEBUG)) {
+                               MDC.put(MDCs.RESPONSE_SEVERITY, MDCs.ResponseSeverityMDC.MDC_DEBUG.toString());
+                       } else if (responseSeverity.equalsIgnoreCase(LoggingConstant.MDC_WARN)) {
+                               MDC.put(MDCs.RESPONSE_SEVERITY, MDCs.ResponseSeverityMDC.MDC_WARN.toString());
+                       } else if (responseSeverity.equalsIgnoreCase(LoggingConstant.MDC_FATAL)) {
+                               MDC.put(MDCs.RESPONSE_SEVERITY, MDCs.ResponseSeverityMDC.MDC_TRACE.toString());
+                       }
+               }
+
        }
+
        public static void clearMDCDetails() {
                MDC.clear();
        }
-       
-       public static String getHostDetails()throws Exception {
+
+       public static String getHostDetails() throws Exception {
                InetAddress ip;
-        String hostname=null;
-        String ipStr=null;
-        String finalHostIP=null;
-        
-            ip = InetAddress.getLocalHost();
-            hostname = ip.getHostName();
-            ipStr=ip.getHostAddress();
-            if(hostname!=null && ipStr!=null) {
-               finalHostIP=hostname+"/"+ipStr;
-            }
-        return finalHostIP;
+               String hostname = null;
+               String ipStr = null;
+               String finalHostIP = null;
+
+               ip = InetAddress.getLocalHost();
+               hostname = ip.getHostName();
+               ipStr = ip.getHostAddress();
+               if (hostname != null && ipStr != null) {
+                       finalHostIP = hostname + "/" + ipStr;
+               }
+               return finalHostIP;
        }
 }
diff --git a/logging-demo/src/main/java/org/acumos/demo/logging/util/LoggingConstant.java b/logging-demo/src/main/java/org/acumos/demo/logging/util/LoggingConstant.java
new file mode 100644 (file)
index 0000000..05fe1ed
--- /dev/null
@@ -0,0 +1,35 @@
+package org.acumos.demo.logging.util;
+
+public final class LoggingConstant {
+
+       public static final String APPLICATION_JSON = "application/json";
+
+       public static final String REQUEST_ID = "RequestID";
+       public static final String TARGET_SERVICENAME = "TargetServiceName";
+       public static final String TARGET_ENTITY = "TargetEntity";
+       public static final String CLIENTIP_ADDRESS = "ClientIPAddress";
+       public static final String SERVER_FQDN = "ServerFQDN";
+       public static final String RESPONSE_CODE = "ResponseCode";
+       public static final String RESPONSE_DESCRIPTION = "ResponseDescription";
+       public static final String SEVERITY = "Severity";
+       public static final String STATUS_CODE = "StatusCode";
+       public static final String USER = "User";
+       public static final String MDC_COMPLETED = "MDC_COMPLETED";
+       public static final String MDC_ERROR = "MDC_ERROR";
+       public static final String MDC_INPROGRESS = "MDC_INPROGRESS";
+       public static final String MDC_INFO = "MDC_INFO";
+       public static final String MDC_TRACE = "MDC_TRACE";
+       public static final String MDC_DEBUG = "MDC_DEBUG";
+       public static final String MDC_WARN = "MDC_WARN";
+       public static final String MDC_FATAL = "MDC_FATAL";
+       public static final String TARGET_SERVICE_NAME = "TargetServiceName";
+       public static final String CLIENT_IP_ADDRESS = "ClientIPAddress";
+       public static final String RESPONSE_SEVERITY = "ResponseSeverity";
+       public static final String INVOKE = "INVOKE";
+       public static final String INVOKE_RETURN = "INVOKE_RETURN";
+       public static final String ENTRY = "ENTRY";
+       public static final String EXIT = "EXIT";
+       public static final String SYNCHRONOUS = "SYNCHRONOUS";
+       public static final String ASYNCHRONOUS = "ASYNCHRONOUS";
+
+}
diff --git a/logging-demo/src/test/java/com/example/demo/DemoApplicationTests.java b/logging-demo/src/test/java/com/example/demo/DemoApplicationTests.java
deleted file mode 100644 (file)
index 02222f4..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-  ===============LICENSE_START=======================================================
-  Acumos
-  ===================================================================================
-  Copyright (C) 2017 AT&T Intellectual Property & Tech Mahindra. All rights reserved.
-  ===================================================================================
-  This Acumos software file is distributed by AT&T and Tech Mahindra
-  under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-   
-          http://www.apache.org/licenses/LICENSE-2.0
-   
-  This file is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
-  ===============LICENSE_END=========================================================
-  */
-package com.example.demo;
-
-import org.acumos.demo.logging.Application;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-public class DemoApplicationTests {
-
-@Test
-public void contextLoads() {
-       }
-
-}