geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [04/22] geode git commit: GEODE-1274: Migration from PulseLogWriter to Log4j standard and removal of associated classes.
Date Thu, 13 Apr 2017 17:18:25 GMT
http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
deleted file mode 100644
index 241b34b..0000000
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogWriter.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information
regarding
- * copyright ownership. The ASF licenses this file to You 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
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
the License
- * 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.
- *
- */
-
-package org.apache.geode.tools.pulse.internal.log;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.geode.tools.pulse.internal.data.PulseConfig;
-import org.apache.geode.tools.pulse.internal.data.Repository;
-
-/**
- * Class PulseLogWriter
- * 
- * PulseLogWriter is the implementation of LogWriter.
- * 
- * @since GemFire 7.0.1
- * 
- */
-public class PulseLogWriter implements LogWriter {
-
-  // Log File handle Object
-  private FileHandler fileHandler;
-
-  // Message Formatter Object
-  private static MessageFormatter messageformatter;
-
-  // pulse log writer
-  private static PulseLogWriter pulseLogger = null;
-
-  // Logger Object
-  private Logger logger;
-
-  private PulseLogWriter() {
-    PulseConfig pulseConfig = Repository.get().getPulseConfig();
-    // Create Logger
-    logger = Logger.getLogger(this.getClass().getName());
-
-    // Set minimum log level to level passed
-    logger.setLevel(pulseConfig.getLogLevel());
-
-    try {
-      // Get file handler to log messages into log file.
-      if (fileHandler == null) {
-        fileHandler =
-            new FileHandler(pulseConfig.getLogFileFullName(), pulseConfig.getLogFileSize(),
-                pulseConfig.getLogFileCount(), pulseConfig.getLogAppend());
-
-        // Log Message Formatter
-        messageformatter = new MessageFormatter();
-        fileHandler.setFormatter(messageformatter);
-      }
-
-      // Add File Handler to logger object
-      logger.addHandler(fileHandler);
-    } catch (SecurityException e) {
-      logger.setUseParentHandlers(true);
-      e.printStackTrace();
-    } catch (IOException e) {
-      logger.setUseParentHandlers(true);
-      e.printStackTrace();
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-  }
-
-  /**
-   * @param jsonErr
-   * @param errorData
-   */
-  public void logJSONError(Exception jsonErr, Object errorData) {
-
-    // print details of thrown exception and data that couldn't be converted to
-    // json
-    if (this.fineEnabled()) {
-
-      // write errors
-      StringWriter swBuffer = new StringWriter();
-      PrintWriter prtWriter = new PrintWriter(swBuffer);
-      jsonErr.printStackTrace(prtWriter);
-      this.fine("JSON Error Details : " + swBuffer.toString() + "\n");
-
-      this.fine("Erroneous Data : "
-          + ((errorData != null) ? errorData.toString() : "Not Available for output") + "\n");
-    }
-  }
-
-  public static synchronized PulseLogWriter getLogger() {
-    if (null == pulseLogger) {
-      pulseLogger = new PulseLogWriter();
-    }
-    return pulseLogger;
-  }
-
-  @Override
-  public boolean severeEnabled() {
-    return logger.isLoggable(Level.SEVERE);
-  }
-
-  @Override
-  public void severe(String msg, Throwable ex) {
-    logger.logp(Level.SEVERE, "", "", msg, ex);
-  }
-
-  @Override
-  public void severe(String msg) {
-    logger.severe(msg);
-  }
-
-  @Override
-  public void severe(Throwable ex) {
-    logger.logp(Level.SEVERE, "", "", "", ex);
-  }
-
-  /*
-   * @Override public boolean errorEnabled() { // TODO Auto-generated method stub return
false; }
-   * 
-   * @Override public void error(String msg, Throwable ex) { // TODO Auto-generated method
stub
-   * 
-   * }
-   * 
-   * @Override public void error(String msg) { // TODO Auto-generated method stub
-   * 
-   * }
-   * 
-   * @Override public void error(Throwable ex) { // TODO Auto-generated method stub
-   * 
-   * }
-   */
-
-  @Override
-  public boolean warningEnabled() {
-    return logger.isLoggable(Level.WARNING);
-  }
-
-  @Override
-  public void warning(String msg, Throwable ex) {
-    logger.logp(Level.WARNING, "", "", msg, ex);
-  }
-
-  @Override
-  public void warning(String msg) {
-    logger.warning(msg);
-  }
-
-  @Override
-  public void warning(Throwable ex) {
-    logger.logp(Level.WARNING, "", "", "", ex);
-  }
-
-  @Override
-  public boolean infoEnabled() {
-    return logger.isLoggable(Level.INFO);
-  }
-
-  @Override
-  public void info(String msg, Throwable ex) {
-    logger.logp(Level.INFO, "", "", msg, ex);
-  }
-
-  @Override
-  public void info(String msg) {
-    logger.info(msg);
-  }
-
-  @Override
-  public void info(Throwable ex) {
-    logger.logp(Level.WARNING, "", "", "", ex);
-  }
-
-  @Override
-  public boolean configEnabled() {
-    return logger.isLoggable(Level.CONFIG);
-  }
-
-  @Override
-  public void config(String msg, Throwable ex) {
-    logger.logp(Level.CONFIG, "", "", msg, ex);
-  }
-
-  @Override
-  public void config(String msg) {
-    logger.config(msg);
-  }
-
-  @Override
-  public void config(Throwable ex) {
-    logger.logp(Level.CONFIG, "", "", "", ex);
-  }
-
-  @Override
-  public boolean fineEnabled() {
-    return logger.isLoggable(Level.FINE);
-  }
-
-  @Override
-  public void fine(String msg, Throwable ex) {
-    logger.logp(Level.FINE, "", "", msg, ex);
-  }
-
-  @Override
-  public void fine(String msg) {
-    logger.fine(msg);
-  }
-
-  @Override
-  public void fine(Throwable ex) {
-    logger.logp(Level.FINE, "", "", "", ex);
-  }
-
-  @Override
-  public boolean finerEnabled() {
-    return logger.isLoggable(Level.FINER);
-  }
-
-  @Override
-  public void finer(String msg, Throwable ex) {
-    logger.logp(Level.FINER, "", "", msg, ex);
-  }
-
-  @Override
-  public void finer(String msg) {
-    logger.finer(msg);
-  }
-
-  @Override
-  public void finer(Throwable ex) {
-    logger.logp(Level.FINER, "", "", "", ex);
-  }
-
-  @Override
-  public void entering(String sourceClass, String sourceMethod) {
-    logger.entering(sourceClass, sourceMethod);
-  }
-
-  @Override
-  public void exiting(String sourceClass, String sourceMethod) {
-    logger.exiting(sourceClass, sourceMethod);
-  }
-
-  @Override
-  public void throwing(String sourceClass, String sourceMethod, Throwable thrown) {
-    logger.throwing(sourceClass, sourceMethod, thrown);
-  }
-
-  @Override
-  public boolean finestEnabled() {
-    return logger.isLoggable(Level.FINEST);
-  }
-
-  @Override
-  public void finest(String msg, Throwable ex) {
-    logger.logp(Level.FINEST, "", "", msg, ex);
-  }
-
-  @Override
-  public void finest(String msg) {
-    logger.finest(msg);
-  }
-
-  @Override
-  public void finest(Throwable ex) {
-    logger.logp(Level.FINEST, "", "", "", ex);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
deleted file mode 100644
index d22f188..0000000
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/log/PulseLogger.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information
regarding
- * copyright ownership. The ASF licenses this file to You 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
- *
- * Unless required by applicable law or agreed to in writing, software distributed under
the License
- * 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.
- *
- */
-
-package org.apache.geode.tools.pulse.internal.log;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import org.apache.geode.tools.pulse.internal.data.PulseConstants;
-
-/**
- * Class PulseLogger
- * 
- * PulseLogger is the custom logger class for Pulse Web Application. It logs messages to
the file in
- * custom format.
- * 
- * @since GemFire version 7.0.Beta
- */
-public class PulseLogger {
-
-  // Pulse Application Log File
-  private static final String LOG_FILE_NAME =
-      PulseConstants.PULSE_LOG_FILE_LOCATION + "/" + PulseConstants.PULSE_LOG_FILE;
-
-  // Date pattern to be used in log messages
-  public static final String LOG_MESSAGE_DATE_PATTERN = "dd/MM/yyyy hh:mm:ss.SSS";
-
-  // The log file size is set to 1MB.
-  public static final int FILE_SIZE = 1024 * 1024;
-
-  // The log file count set to 1 files.
-  public static final int FILE_COUNT = 5;
-
-  // Append logs is set to true.
-  public static final boolean FLAG_APPEND = true;
-
-  // Log File handle Object
-  private static FileHandler fileHandler;
-
-  // Message Formatter Object
-  private static MessageFormatter messageformatter;
-
-  // Logger Object
-  private static Logger logger;
-
-  public static Logger getLogger(String name) {
-    // Create Logger
-    logger = Logger.getLogger(name);
-
-    // Set minimum log level to inform
-    logger.setLevel(Level.INFO);
-
-    // Get file handler to log messages into log file.
-    try {
-      // fileHandler = new FileHandler(LOG_FILE_NAME, FILE_SIZE, FILE_COUNT,
-      // FLAG_APPEND);
-      fileHandler = new FileHandler(LOG_FILE_NAME, FLAG_APPEND);
-
-      // Log Message Formatter
-      messageformatter = new MessageFormatter();
-
-      fileHandler.setFormatter(messageformatter);
-
-      // Add File Handler to logger object
-      logger.addHandler(fileHandler);
-
-    } catch (SecurityException e) {
-      e.printStackTrace();
-    } catch (IOException e) {
-      e.printStackTrace();
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-
-    return logger;
-  }
-
-  /**
-   * Class MessageFormatter
-   * 
-   * MessageFormatter is the custom formatter class for formatting the log messages.
-   * 
-   * @since GemFire version 7.0.Beta 2012-09-23
-   */
-  private static class MessageFormatter extends Formatter {
-
-    public MessageFormatter() {
-      super();
-    }
-
-    @Override
-    public String format(LogRecord record) {
-      // Set DateFormat
-      DateFormat df = new SimpleDateFormat(PulseLogger.LOG_MESSAGE_DATE_PATTERN);
-      StringBuilder builder = new StringBuilder(1000);
-
-      // Format Log Message
-      builder.append(df.format(new Date(record.getMillis()))).append(" - ");
-      builder.append("[ " + PulseConstants.APP_NAME + " ] - ");
-      builder.append("[").append(record.getSourceClassName()).append(".");
-      builder.append(record.getSourceMethodName()).append("] - ");
-      builder.append("[").append(record.getLevel()).append("] - ");
-      builder.append(formatMessage(record));
-      builder.append(System.getProperty("line.separator"));
-
-      return builder.toString();
-    }
-
-    public String getHead(Handler h) {
-      return super.getHead(h);
-    }
-
-    public String getTail(Handler h) {
-      return super.getTail(h);
-    }
-  } // End of Class MessageFormatter
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
index 884e51f..dc75735 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthentication.java
@@ -22,7 +22,6 @@ import javax.management.ObjectName;
 import javax.management.remote.JMXConnector;
 
 import org.apache.geode.tools.pulse.internal.data.PulseConstants;
-import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
 
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.GrantedAuthority;
@@ -48,8 +47,6 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
  */
 public class GemFireAuthentication extends UsernamePasswordAuthenticationToken {
 
-  private final static PulseLogWriter logger = PulseLogWriter.getLogger();
-
   private JMXConnector jmxc = null;
 
   public GemFireAuthentication(Object principal, Object credentials,

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
index 4d300f0..096bf6f 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/GemFireAuthenticationProvider.java
@@ -18,8 +18,9 @@ import java.util.Collection;
 import javax.management.remote.JMXConnector;
 
 import org.apache.geode.tools.pulse.internal.data.Repository;
-import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
 
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.springframework.security.authentication.AuthenticationProvider;
 import org.springframework.security.authentication.AuthenticationServiceException;
 import org.springframework.security.authentication.BadCredentialsException;
@@ -37,7 +38,7 @@ import org.springframework.security.core.GrantedAuthority;
  */
 public class GemFireAuthenticationProvider implements AuthenticationProvider {
 
-  private final static PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+  private static final Logger logger = LogManager.getLogger();
 
   public GemFireAuthenticationProvider() {}
 
@@ -46,7 +47,7 @@ public class GemFireAuthenticationProvider implements AuthenticationProvider
{
 
     if (authentication instanceof GemFireAuthentication) {
       GemFireAuthentication gemAuth = (GemFireAuthentication) authentication;
-      LOGGER.fine("GemAuthentication is connected? = " + gemAuth.getJmxc());
+      logger.debug("GemAuthentication is connected? = {}", gemAuth.getJmxc());
       if (gemAuth.getJmxc() != null && gemAuth.isAuthenticated())
         return gemAuth;
     }
@@ -55,13 +56,13 @@ public class GemFireAuthenticationProvider implements AuthenticationProvider
{
     String password = authentication.getCredentials().toString();
 
     try {
-      LOGGER.fine("Connecting to GemFire with user=" + name);
+      logger.debug("Connecting to GemFire with user={}", name);
       JMXConnector jmxc = Repository.get().getCluster(name, password).connectToGemFire();
       if (jmxc != null) {
         Collection<GrantedAuthority> list = GemFireAuthentication.populateAuthorities(jmxc);
         GemFireAuthentication auth = new GemFireAuthentication(authentication.getPrincipal(),
             authentication.getCredentials(), list, jmxc);
-        LOGGER.fine("For user " + name + " authList=" + list);
+        logger.debug("For user " + name + " authList={}", list);
         return auth;
       } else {
         throw new AuthenticationServiceException("JMX Connection unavailable");

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
index e18e35d..b169d4f 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/security/LogoutHandler.java
@@ -20,8 +20,9 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.geode.tools.pulse.internal.data.Repository;
-import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
 
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.springframework.security.core.Authentication;
 import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
 import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
@@ -31,6 +32,7 @@ import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuc
  *
  */
 public class LogoutHandler extends SimpleUrlLogoutSuccessHandler implements LogoutSuccessHandler
{
+  private static final Logger logger = LogManager.getLogger();
 
   public LogoutHandler(String defaultTargetURL) {
     this.setDefaultTargetUrl(defaultTargetURL);
@@ -38,13 +40,12 @@ public class LogoutHandler extends SimpleUrlLogoutSuccessHandler implements
Logo
 
   public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response,
       Authentication authentication) throws IOException, ServletException {
-    PulseLogWriter LOGGER = PulseLogWriter.getLogger();
-    LOGGER.fine("Invoked #LogoutHandler ...");
+    logger.debug("Invoked #LogoutHandler ...");
     if (Repository.get().isUseGemFireCredentials()) {
       GemFireAuthentication gemauthentication = (GemFireAuthentication) authentication;
       if (gemauthentication != null) {
         gemauthentication.getJmxc().close();
-        LOGGER.info("#LogoutHandler : Closing GemFireAuthentication JMX Connection...");
+        logger.info("#LogoutHandler : Closing GemFireAuthentication JMX Connection...");
       }
     }
     super.onLogoutSuccess(request, response, authentication);

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
index a088ccb..2287174 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionService.java
@@ -25,8 +25,9 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.geode.tools.pulse.internal.data.Cluster;
 import org.apache.geode.tools.pulse.internal.data.PulseConstants;
 import org.apache.geode.tools.pulse.internal.data.Repository;
-import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
 import org.apache.geode.tools.pulse.internal.util.TimeUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
@@ -52,6 +53,7 @@ import javax.servlet.http.HttpServletRequest;
 public class ClusterSelectedRegionService implements PulseService {
 
   private final ObjectMapper mapper = new ObjectMapper();
+  private static final Logger logger = LogManager.getLogger();
 
   // String constants used for forming a json response
   private final String ENTRY_SIZE = "entrySize";
@@ -100,7 +102,6 @@ public class ClusterSelectedRegionService implements PulseService {
    * @return ObjectNode Array List
    */
   private ObjectNode getSelectedRegionJson(Cluster cluster, String selectedRegionFullPath)
{
-    PulseLogWriter LOGGER = PulseLogWriter.getLogger();
     Long totalHeapSize = cluster.getTotalHeapSize();
     Long totalDiskUsage = cluster.getTotalBytesOnDisk();
 
@@ -218,7 +219,7 @@ public class ClusterSelectedRegionService implements PulseService {
       regionJSON.put("totalDataUsage", totalDiskUsage);
       regionJSON.put("memoryUsage", entrySizeInMB);
 
-      LOGGER.fine("calling getSelectedRegionJson :: regionJSON = " + regionJSON);
+      logger.debug("calling getSelectedRegionJson :: regionJSON = {}", regionJSON);
       return regionJSON;
     } else {
       ObjectNode responseJSON = mapper.createObjectNode();

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
index d5a9137..cba95a0 100644
--- a/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
+++ b/geode-pulse/src/main/java/org/apache/geode/tools/pulse/internal/service/ClusterSelectedRegionsMemberService.java
@@ -20,10 +20,12 @@ package org.apache.geode.tools.pulse.internal.service;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+
 import org.apache.geode.tools.pulse.internal.data.Cluster;
 import org.apache.geode.tools.pulse.internal.data.Cluster.RegionOnMember;
 import org.apache.geode.tools.pulse.internal.data.Repository;
-import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
@@ -49,6 +51,7 @@ import java.util.List;
 public class ClusterSelectedRegionsMemberService implements PulseService {
 
   private final ObjectMapper mapper = new ObjectMapper();
+  private static final Logger logger = LogManager.getLogger();
 
   // Comparator based upon regions entry count
   private static Comparator<Cluster.RegionOnMember> romEntryCountComparator = (m1,
m2) -> {
@@ -65,14 +68,13 @@ public class ClusterSelectedRegionsMemberService implements PulseService
{
 
   @Override
   public ObjectNode execute(final HttpServletRequest request) throws Exception {
-    PulseLogWriter LOGGER = PulseLogWriter.getLogger();
     String userName = request.getUserPrincipal().getName();
     String pulseData = request.getParameter("pulseData");
     JsonNode parameterMap = mapper.readTree(pulseData);
     String selectedRegionFullPath =
         parameterMap.get("ClusterSelectedRegionsMember").get("regionFullPath").textValue();
-    LOGGER.finest(
-        "ClusterSelectedRegionsMemberService selectedRegionFullPath = " + selectedRegionFullPath);
+    logger.trace("ClusterSelectedRegionsMemberService selectedRegionFullPath = {}",
+        selectedRegionFullPath);
 
     // get cluster object
     Cluster cluster = Repository.get().getCluster();
@@ -93,7 +95,6 @@ public class ClusterSelectedRegionsMemberService implements PulseService
{
    * Create JSON for selected cluster region's all members
    */
   private ObjectNode getSelectedRegionsMembersJson(Cluster cluster, String selectedRegionFullPath)
{
-    PulseLogWriter LOGGER = PulseLogWriter.getLogger();
     Cluster.Region reg = cluster.getClusterRegion(selectedRegionFullPath);
 
     if (reg != null) {
@@ -112,37 +113,36 @@ public class ClusterSelectedRegionsMemberService implements PulseService
{
         memberJSON.put("entrySize", rom.getEntrySize());
 
         memberJSON.put("accessor", ((rom.getLocalMaxMemory() == 0) ? "True" : "False"));
-        LOGGER.finest("calling getSelectedRegionsMembersJson :: rom.getLocalMaxMemory() =
"
-            + rom.getLocalMaxMemory());
+        logger.trace("calling getSelectedRegionsMembersJson :: rom.getLocalMaxMemory() =
{}",
+            rom.getLocalMaxMemory());
 
         memberJSON.put("memoryReadsTrend",
             mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(
                 RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND)));
-        LOGGER.finest("memoryReadsTrend = " + rom.getRegionOnMemberStatisticTrend(
+        logger.trace("memoryReadsTrend = {}", rom.getRegionOnMemberStatisticTrend(
             RegionOnMember.REGION_ON_MEMBER_STAT_GETS_PER_SEC_TREND).length);
 
         memberJSON.put("memoryWritesTrend",
             mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(
                 RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND)));
-        LOGGER.finest("memoryWritesTrend = " + rom.getRegionOnMemberStatisticTrend(
+        logger.trace("memoryWritesTrend = {}", rom.getRegionOnMemberStatisticTrend(
             RegionOnMember.REGION_ON_MEMBER_STAT_PUTS_PER_SEC_TREND).length);
-
         memberJSON.put("diskReadsTrend",
             mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(
                 RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND)));
-        LOGGER.finest("diskReadsTrend = " + rom.getRegionOnMemberStatisticTrend(
+        logger.trace("diskReadsTrend = {}", rom.getRegionOnMemberStatisticTrend(
             RegionOnMember.REGION_ON_MEMBER_STAT_DISK_READS_PER_SEC_TREND).length);
 
         memberJSON.put("diskWritesTrend",
             mapper.<JsonNode>valueToTree(rom.getRegionOnMemberStatisticTrend(
                 RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND)));
-        LOGGER.finest("diskWritesTrend = " + rom.getRegionOnMemberStatisticTrend(
+        logger.trace("diskWritesTrend = {}", rom.getRegionOnMemberStatisticTrend(
             RegionOnMember.REGION_ON_MEMBER_STAT_DISK_WRITES_PER_SEC_TREND).length);
 
         regionMemberJSON.put(rom.getMemberName(), memberJSON);
       }
 
-      LOGGER.fine("calling getSelectedRegionsMembersJson :: regionJSON = " + regionMemberJSON);
+      logger.debug("calling getSelectedRegionsMembersJson :: regionJSON = {}", regionMemberJSON);
       return regionMemberJSON;
     } else {
       ObjectNode responseJSON = mapper.createObjectNode();

http://git-wip-us.apache.org/repos/asf/geode/blob/31b65074/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
index df31572..6ee5b53 100644
--- a/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
+++ b/geode-pulse/src/test/java/org/apache/geode/tools/pulse/testbed/PropMockDataUpdater.java
@@ -28,10 +28,11 @@ import org.apache.geode.tools.pulse.internal.data.Cluster.Region;
 import org.apache.geode.tools.pulse.internal.data.IClusterUpdater;
 import org.apache.geode.tools.pulse.internal.data.PulseConstants;
 import org.apache.geode.tools.pulse.internal.data.Repository;
-import org.apache.geode.tools.pulse.internal.log.PulseLogWriter;
 import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Locator;
 import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Peer;
 import org.apache.geode.tools.pulse.testbed.GemFireDistributedSystem.Server;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
@@ -47,7 +48,7 @@ import java.util.ResourceBundle;
 
 public class PropMockDataUpdater implements IClusterUpdater {
   private static final int MAX_HOSTS = 40;
-  private static final PulseLogWriter LOGGER = PulseLogWriter.getLogger();
+  private static final Logger logger = LogManager.getLogger();
   private final ResourceBundle resourceBundle = Repository.get().getResourceBundle();
   private static final int POLL_INTERVAL = 5000;
   public static final int MAX_SAMPLE_SIZE = 180;
@@ -412,9 +413,7 @@ public class PropMockDataUpdater implements IClusterUpdater {
    */
 
   private void refresh(Member m) {
-    if (LOGGER.infoEnabled()) {
-      LOGGER.info(resourceBundle.getString("LOG_MSG_REFRESHING_MEMBER_DATA") + " : " + m.getName());
-    }
+    logger.info("{} : {}", resourceBundle.getString("LOG_MSG_REFRESHING_MEMBER_DATA"), m.getName());
 
     Random r = new Random(System.currentTimeMillis());
 


Mime
View raw message