Fix for Sonar critical issues 11/12411/4
authorrama-huawei <rama.subba.reddy.s@huawei.com>
Thu, 14 Sep 2017 10:28:53 +0000 (15:58 +0530)
committerRama SubbaReddy <rama.subba.reddy.s@huawei.com>
Thu, 14 Sep 2017 11:38:02 +0000 (11:38 +0000)
DCAEGEN2-93

Change-Id: I31edc7ff781d1d2522bd0ab0df440cc38ee24e3a
Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
src/main/java/com/att/nsa/mr/logging/MRAppender.java

index 8faf0df..364f36d 100644 (file)
@@ -26,8 +26,10 @@ package com.att.nsa.mr.logging;
 
 import java.io.IOException;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.helpers.LogLog;
 import org.apache.log4j.spi.LoggingEvent;
 
 import com.att.nsa.mr.client.MRClientFactory;
@@ -39,6 +41,8 @@ import com.att.nsa.mr.client.MRPublisher;
  */
 public class MRAppender extends AppenderSkeleton {
 
+       private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
        private MRPublisher fPublisher;
 
        //Provided through log4j configuration
@@ -98,7 +102,7 @@ public class MRAppender extends AppenderSkeleton {
                try {
                        fPublisher.send(partition, message);
                } catch (IOException e) {
-                       e.printStackTrace();
+                    logger.error("IOException: ", e);
                }
        }
 
@@ -106,7 +110,7 @@ public class MRAppender extends AppenderSkeleton {
                if (hosts != null && topic != null && partition != null) {
                        fPublisher = MRClientFactory.createBatchingPublisher(hosts.split(","), topic, maxBatchSize, maxAgeMs, compress);
                } else {
-                       LogLog.error("The Hosts, Topic, and Partition parameter are required to create a MR Log4J Appender");
+                       logger.error("The Hosts, Topic, and Partition parameter are required to create a MR Log4J Appender");
                }
        }
        public String getTopic() {