geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kh...@apache.org
Subject [21/35] geode git commit: GEODE-2634: use log4j levels for auto-completion
Date Tue, 28 Mar 2017 16:46:49 GMT
GEODE-2634: use log4j levels for auto-completion

* change the auto complete to use log4j levels.
* be able to handle both log4j levels and logwriter levels in the commands
* add validation of log level whenever possible for these commands
* Move the conversion between the two to a LogLevel class and add unit tests


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/f722c516
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/f722c516
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/f722c516

Branch: refs/heads/feature/GEODE-2420
Commit: f722c516192a52485382cbc9d1640fcc3d4e4ec4
Parents: 0deb957
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Wed Mar 15 14:36:50 2017 -0700
Committer: Ken Howe <khowe@pivotal.io>
Committed: Mon Mar 27 14:01:44 2017 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/geode/LogWriter.java   |   5 +-
 .../internal/DistributedSystemConfigImpl.java   |  34 +++-
 .../internal/AbstractDistributionConfig.java    |   3 +-
 .../org/apache/geode/i18n/LogWriterI18n.java    |   5 +-
 .../internal/admin/remote/RemoteAlert.java      |   3 +-
 .../geode/internal/logging/GemFireLevel.java    |  95 -----------
 .../geode/internal/logging/LogWriterImpl.java   |  14 +-
 .../geode/internal/logging/log4j/LogLevel.java  | 167 +++++++++++++++++++
 .../logging/log4j/LogWriterAppender.java        |  15 +-
 .../internal/logging/log4j/LogWriterLogger.java |  96 +----------
 .../management/internal/MemberMessenger.java    |  12 +-
 .../internal/cli/commands/ConfigCommands.java   |  19 ++-
 .../cli/commands/ExportLogsCommand.java         |   8 +-
 .../cli/commands/LauncherLifecycleCommands.java |   2 -
 .../cli/commands/MiscellaneousCommands.java     |  39 ++---
 .../cli/converters/LogLevelConverter.java       |  17 +-
 .../cli/functions/ChangeLogLevelFunction.java   |   3 +-
 .../cli/functions/ExportLogsFunction.java       |   3 +-
 .../internal/cli/util/LogLevelExtractor.java    |  27 +--
 .../internal/cli/util/ReadWriteFile.java        |  11 +-
 .../internal/DistributionConfigJUnitTest.java   |  54 ++++--
 .../internal/logging/log4j/LogLevelTest.java    | 119 +++++++++++++
 .../ExportLogsInterceptorJUnitTest.java         |   7 -
 .../cli/commands/LogLevelInterceptorTest.java   |  82 +++++++++
 .../cli/converters/LogLevelConverterTest.java   |  47 ++++++
 .../ExportLogsFunctionIntegrationTest.java      |  10 ++
 .../cli/util/LogLevelExtractorTest.java         |  21 ---
 27 files changed, 590 insertions(+), 328 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/LogWriter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/LogWriter.java b/geode-core/src/main/java/org/apache/geode/LogWriter.java
index 242433f..4a2e473 100644
--- a/geode-core/src/main/java/org/apache/geode/LogWriter.java
+++ b/geode-core/src/main/java/org/apache/geode/LogWriter.java
@@ -15,11 +15,11 @@
 
 package org.apache.geode;
 
-import java.util.logging.Handler;
-
 import org.apache.geode.distributed.DistributedSystem;
 import org.apache.geode.i18n.LogWriterI18n;
 
+import java.util.logging.Handler;
+
 /**
  * Defines methods available to clients that want to write a log message to their GemFire
  * distributed system log file.
@@ -74,6 +74,7 @@ import org.apache.geode.i18n.LogWriterI18n;
  * <em>level</em><code>Enabled</code>.
  *
  */
+@Deprecated
 public interface LogWriter {
 
   /**

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
index a89d390..7a75612 100755
--- a/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/admin/internal/DistributedSystemConfigImpl.java
@@ -14,7 +14,24 @@
  */
 package org.apache.geode.admin.internal;
 
-import org.apache.geode.admin.*;
+import static org.apache.geode.distributed.ConfigurationProperties.BIND_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_CIPHERS;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_PROTOCOLS;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_REQUIRE_AUTHENTICATION;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_AUTO_RECONNECT;
+import static org.apache.geode.distributed.ConfigurationProperties.DISABLE_TCP;
+import static org.apache.geode.distributed.ConfigurationProperties.LOCATORS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_ADDRESS;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.TCP_PORT;
+
+import org.apache.geode.admin.AdminXmlException;
+import org.apache.geode.admin.CacheServerConfig;
+import org.apache.geode.admin.CacheVmConfig;
+import org.apache.geode.admin.DistributedSystemConfig;
+import org.apache.geode.admin.DistributionLocator;
+import org.apache.geode.admin.DistributionLocatorConfig;
 import org.apache.geode.distributed.internal.DistributionConfig;
 import org.apache.geode.distributed.internal.DistributionConfigImpl;
 import org.apache.geode.internal.i18n.LocalizedStrings;
@@ -22,15 +39,20 @@ import org.apache.geode.internal.logging.InternalLogWriter;
 import org.apache.geode.internal.logging.LogConfig;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.LogWriterImpl;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.logging.log4j.Logger;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.*;
-
-import static org.apache.geode.distributed.ConfigurationProperties.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
 
 /**
  * An implementation of the configuration object for an <code>AdminDistributedSystem</code>. After a
@@ -252,7 +274,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
     return new LogConfig() {
       @Override
       public int getLogLevel() {
-        return LogWriterImpl.levelNameToCode(DistributedSystemConfigImpl.this.getLogLevel());
+        return LogLevel.getLogWriterLevel(DistributedSystemConfigImpl.this.getLogLevel());
       }
 
       @Override
@@ -992,7 +1014,7 @@ public class DistributedSystemConfigImpl implements DistributedSystemConfig {
     // "mcastPort must be zero when locators are specified");
     // }
 
-    LogWriterImpl.levelNameToCode(this.logLevel);
+    LogLevel.getLogWriterLevel(this.logLevel);
 
     if (this.logFileSizeLimit < MIN_LOG_FILE_SIZE_LIMIT
         || this.logFileSizeLimit > MAX_LOG_FILE_SIZE_LIMIT) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
index decb61d..2c6c025 100644
--- a/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
+++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/AbstractDistributionConfig.java
@@ -25,6 +25,7 @@ import org.apache.geode.internal.ConfigSource;
 import org.apache.geode.internal.admin.remote.DistributionLocatorId;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.LogWriterImpl;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.internal.net.SocketCreator;
 import org.apache.geode.internal.security.SecurableCommunicationChannel;
 import org.apache.geode.memcached.GemFireMemcachedServer;
@@ -571,7 +572,7 @@ public abstract class AbstractDistributionConfig extends AbstractConfig
     // accepts int
     if (attName.equalsIgnoreCase(LOG_LEVEL) || attName.equalsIgnoreCase(SECURITY_LOG_LEVEL)) {
       if (attValue instanceof String) {
-        attValue = LogWriterImpl.levelNameToCode((String) attValue);
+        attValue = LogLevel.getLogWriterLevel((String) attValue);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/i18n/LogWriterI18n.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/i18n/LogWriterI18n.java b/geode-core/src/main/java/org/apache/geode/i18n/LogWriterI18n.java
index b9a4df3..fd7d331 100644
--- a/geode-core/src/main/java/org/apache/geode/i18n/LogWriterI18n.java
+++ b/geode-core/src/main/java/org/apache/geode/i18n/LogWriterI18n.java
@@ -15,11 +15,11 @@
 
 package org.apache.geode.i18n;
 
-import java.util.logging.Handler;
-
 import org.apache.geode.LogWriter;
 import org.apache.geode.distributed.DistributedSystem;
 
+import java.util.logging.Handler;
+
 /**
  * Defines methods available to clients that want to write a log message to their GemFire
  * distributed system log file.
@@ -74,6 +74,7 @@ import org.apache.geode.distributed.DistributedSystem;
  * <em>level</em><code>Enabled</code>.
  *
  */
+@Deprecated
 public interface LogWriterI18n {
   /**
    * @return true if "severe" log messages are enabled.

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteAlert.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteAlert.java b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteAlert.java
index 1783e90..74266a7 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteAlert.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/admin/remote/RemoteAlert.java
@@ -20,6 +20,7 @@ import org.apache.geode.internal.admin.*;
 import org.apache.geode.internal.i18n.LocalizedStrings;
 import org.apache.geode.internal.logging.DateFormatter;
 import org.apache.geode.internal.logging.LogWriterImpl;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 
 import java.io.*;
 import java.util.*;
@@ -117,7 +118,7 @@ public class RemoteAlert implements Alert {
     String stamp = s.substring(firstBracket, lastBracket);
     StringTokenizer st = new StringTokenizer(stamp, "[ ");
 
-    final int level = LogWriterImpl.levelNameToCode(st.nextToken());
+    final int level = LogLevel.getLogWriterLevel(st.nextToken());
 
     StringBuffer sb = new StringBuffer();
     sb.append(st.nextToken());

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java b/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
deleted file mode 100644
index 0e1dc6e..0000000
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/GemFireLevel.java
+++ /dev/null
@@ -1,95 +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.internal.logging;
-
-import org.apache.geode.i18n.LogWriterI18n;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-
-import java.util.logging.Level;
-
-/**
- * Extension that adds ERROR to the standard JDK logging level class.
- * 
- * @deprecated use log4j level
- */
-public class GemFireLevel extends Level {
-  private static final long serialVersionUID = -8123818329485173242L;
-  /**
-   * ERROR is a message level indicating a problem. Unlike WARNING its not a potential problem.
-   * Unlike SEVERE its not terminal.
-   * 
-   * In general ERROR messages should describe events that are of considerable importance but will
-   * not prevent program execution. They should be reasonably intelligible to end users and to
-   * system administrators. This level is initialized to 950.
-   */
-  public static final Level ERROR = new GemFireLevel("error", InternalLogWriter.ERROR_LEVEL);
-
-  public static Level create(int code) {
-    switch (code) {
-      case InternalLogWriter.ALL_LEVEL:
-        return ALL;
-      case InternalLogWriter.FINEST_LEVEL:
-        return FINEST;
-      case InternalLogWriter.FINER_LEVEL:
-        return FINER;
-      case InternalLogWriter.FINE_LEVEL:
-        return FINE;
-      case InternalLogWriter.CONFIG_LEVEL:
-        return CONFIG;
-      case InternalLogWriter.INFO_LEVEL:
-        return INFO;
-      case InternalLogWriter.WARNING_LEVEL:
-        return WARNING;
-      case InternalLogWriter.ERROR_LEVEL:
-        return ERROR;
-      case InternalLogWriter.SEVERE_LEVEL:
-        return SEVERE;
-      case InternalLogWriter.NONE_LEVEL:
-        return OFF;
-      default:
-        throw new IllegalArgumentException(LocalizedStrings.GemFireLevel_UNEXPECTED_LEVEL_CODE_0
-            .toLocalizedString(Integer.valueOf(code)));
-    }
-  }
-
-  public static Level create(LogWriterI18n log) {
-    if (log.finestEnabled())
-      return FINEST;
-    if (log.finerEnabled())
-      return FINER;
-    if (log.fineEnabled())
-      return FINE;
-    if (log.configEnabled())
-      return CONFIG;
-    if (log.infoEnabled())
-      return INFO;
-    if (log.warningEnabled())
-      return WARNING;
-    if (log.errorEnabled())
-      return ERROR;
-    if (log.severeEnabled())
-      return SEVERE;
-
-    return OFF;
-  }
-
-  private GemFireLevel(String name, int code) {
-    super(name, code);
-  }
-
-  protected Object readResolve() {
-    return create(this.intValue());
-  }
-}

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterImpl.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterImpl.java b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterImpl.java
index 57f0a5c..f97451c 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterImpl.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/LogWriterImpl.java
@@ -14,6 +14,12 @@
  */
 package org.apache.geode.internal.logging;
 
+import org.apache.geode.i18n.LogWriterI18n;
+import org.apache.geode.i18n.StringId;
+import org.apache.geode.internal.Assert;
+import org.apache.geode.internal.i18n.LocalizedStrings;
+import org.apache.geode.internal.process.StartupStatusListener;
+
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.text.BreakIterator;
@@ -26,12 +32,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Handler;
 import java.util.logging.Level;
 
-import org.apache.geode.i18n.LogWriterI18n;
-import org.apache.geode.internal.Assert;
-import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.process.StartupStatusListener;
-import org.apache.geode.i18n.StringId;
-
 /**
  * Abstract implementation of {@link InternalLogWriter}. Each logger has a level and it will only
  * print messages whose level is greater than or equal to the logger's level. The supported logger
@@ -56,6 +56,7 @@ import org.apache.geode.i18n.StringId;
  * <li>{@link #put(int, StringId, Object[], Throwable)}
  * </ol>
  */
+@Deprecated
 public abstract class LogWriterImpl implements InternalLogWriter {
 
   // Constants
@@ -201,6 +202,7 @@ public abstract class LogWriterImpl implements InternalLogWriter {
    * Gets the level code for the given <code>levelName</code>.
    * 
    * @throws IllegalArgumentException if an unknown level name is given.
+   * @deprecated
    */
   public static int levelNameToCode(String levelName) {
     if ("all".equalsIgnoreCase(levelName)) {

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogLevel.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogLevel.java b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogLevel.java
new file mode 100644
index 0000000..a1c5035
--- /dev/null
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogLevel.java
@@ -0,0 +1,167 @@
+/*
+ * 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.internal.logging.log4j;
+
+import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.logging.log4j.Level;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * This class provides utility methods to hold all valid log4j levels and lgegacy geode log levels
+ * and the mapping between the two level hierarchy.
+ */
+public class LogLevel {
+
+  private static Map<String, Level> LEVELS = new HashMap<>();
+  private static Map<String, Integer> S2I = new HashMap<>();
+  private static Map<Integer, String> I2S = new HashMap<>();
+
+  static {
+    // logwriter int level to log4j level string
+    I2S.put(InternalLogWriter.NONE_LEVEL, "OFF");
+    I2S.put(InternalLogWriter.SEVERE_LEVEL, "FATAL");
+    I2S.put(InternalLogWriter.ERROR_LEVEL, "ERROR");
+    I2S.put(InternalLogWriter.WARNING_LEVEL, "WARN");
+    I2S.put(InternalLogWriter.INFO_LEVEL, "INFO");
+    I2S.put(InternalLogWriter.CONFIG_LEVEL, "INFO");
+    I2S.put(InternalLogWriter.FINE_LEVEL, "DEBUG");
+    I2S.put(InternalLogWriter.FINER_LEVEL, "TRACE");
+    I2S.put(InternalLogWriter.FINEST_LEVEL, "TRACE");
+    I2S.put(InternalLogWriter.ALL_LEVEL, "ALL");
+
+    // logwriter strings to integer
+    S2I.put("NONE", InternalLogWriter.NONE_LEVEL);
+    S2I.put("SEVERE", InternalLogWriter.SEVERE_LEVEL);
+    S2I.put("ERROR", InternalLogWriter.ERROR_LEVEL);
+    S2I.put("WARNING", InternalLogWriter.WARNING_LEVEL);
+    S2I.put("INFO", InternalLogWriter.INFO_LEVEL);
+    S2I.put("CONFIG", InternalLogWriter.CONFIG_LEVEL);
+    S2I.put("FINE", InternalLogWriter.FINE_LEVEL);
+    S2I.put("FINER", InternalLogWriter.FINER_LEVEL);
+    S2I.put("FINEST", InternalLogWriter.FINEST_LEVEL);
+    S2I.put("ALL", InternalLogWriter.ALL_LEVEL);
+
+    // additional log4j strings to integer
+    S2I.put("OFF", InternalLogWriter.NONE_LEVEL);
+    S2I.put("FATAL", InternalLogWriter.SEVERE_LEVEL);
+    S2I.put("WARN", InternalLogWriter.WARNING_LEVEL);
+    S2I.put("DEBUG", InternalLogWriter.FINE_LEVEL);
+    S2I.put("TRACE", InternalLogWriter.FINEST_LEVEL);
+
+    // put all the log4j levels in the map first
+    Arrays.stream(Level.values()).forEach(level -> {
+      LEVELS.put(level.name(), level);
+    });
+    // map all the other logwriter level to log4j levels
+    LEVELS.put("SEVERE", getLog4jLevel(InternalLogWriter.SEVERE_LEVEL));
+    LEVELS.put("WARNING", getLog4jLevel(InternalLogWriter.WARNING_LEVEL));
+    LEVELS.put("CONFIG", getLog4jLevel(InternalLogWriter.CONFIG_LEVEL));
+    LEVELS.put("FINE", getLog4jLevel(InternalLogWriter.FINE_LEVEL));
+    LEVELS.put("FINER", getLog4jLevel(InternalLogWriter.FINER_LEVEL));
+    LEVELS.put("FINEST", getLog4jLevel(InternalLogWriter.FINEST_LEVEL));
+    LEVELS.put("NONE", getLog4jLevel(InternalLogWriter.NONE_LEVEL));
+  }
+
+  /**
+   * resolve the log4j level from any log statement in the log file.
+   * 
+   * @param level either legacy level string or log4j level string
+   * @return log4j level. Level.OFF is invalid string
+   */
+  public static Level resolveLevel(String level) {
+    Level log4jLevel = LEVELS.get(level.toUpperCase());
+    // make sure any unrecognizable log level is assigned a most specific level
+    return log4jLevel == null ? Level.OFF : log4jLevel;
+  }
+
+  /**
+   * get Log4j Level from either legacy level string or log4j level string
+   * 
+   * @param level either legacy level string or log4j level string
+   * @return log4j level. null if invalid level string
+   */
+  public static Level getLevel(String level) {
+    return LEVELS.get(level.toUpperCase());
+  }
+
+  /**
+   * convert log4j level to logwriter code
+   * 
+   * @param log4jLevel log4j level object
+   * @return legacy logwriter code
+   */
+  public static int getLogWriterLevel(final Level log4jLevel) {
+    Integer result = S2I.get(log4jLevel.name());
+
+    if (result == null)
+      throw new IllegalArgumentException("Unknown Log4J level [" + log4jLevel + "].");
+
+    return result;
+  }
+
+  /**
+   * convert legacy logwriter code to log4j level
+   * 
+   * @param logWriterLevel logwriter code
+   * @return log4j level
+   */
+  public static Level getLog4jLevel(final int logWriterLevel) {
+    String log4jLevel = I2S.get(logWriterLevel);
+    if (log4jLevel == null)
+      throw new IllegalArgumentException("Unknown LogWriter level [" + logWriterLevel + "].");
+    return Level.getLevel(log4jLevel);
+  }
+
+  /**
+   * convert a string to logwriter code, either log4j level or logwriter string, or a level-xxx
+   * 
+   * @param levelName a string of level name
+   * @return logwriter code
+   */
+  public static int getLogWriterLevel(String levelName) {
+    if (levelName == null) {
+      throw new IllegalArgumentException("Levalname can't be null");
+    }
+
+    Integer level = S2I.get(levelName.toUpperCase());
+    if (level != null)
+      return level;
+
+    if (levelName.startsWith("level-")) {
+      String levelValue = levelName.substring("level-".length());
+      return Integer.parseInt(levelValue);
+    }
+
+    String values =
+        Arrays.stream(Level.values()).sorted().map(Level::name).collect(Collectors.joining(", "));
+    throw new IllegalArgumentException(
+        "Unknown log-level \"" + levelName + "\". Valid levels are: " + values + ".");
+  }
+
+  /**
+   * convert a legacy logwriter code to log4j level string
+   * 
+   * @param logWriterLevel integer code
+   * @return log4j level string
+   */
+  public static String getLog4jLevelAsString(int logWriterLevel) {
+    return getLog4jLevel(logWriterLevel).name().toLowerCase();
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterAppender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterAppender.java b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterAppender.java
index 031a306..61cbd45 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterAppender.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterAppender.java
@@ -14,17 +14,10 @@
  */
 package org.apache.geode.internal.logging.log4j;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
 import org.apache.geode.internal.logging.LogConfig;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.ManagerLogWriter;
 import org.apache.geode.internal.logging.PureLogWriter;
-
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.LoggerContext;
@@ -32,6 +25,12 @@ import org.apache.logging.log4j.core.appender.AbstractAppender;
 import org.apache.logging.log4j.core.config.LoggerConfig;
 import org.apache.logging.log4j.core.layout.PatternLayout;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
 /**
  * A Log4j Appender which will copy all output to a LogWriter.
  * 
@@ -92,7 +91,7 @@ public class LogWriterAppender extends AbstractAppender implements PropertyChang
     }
     appending.set(Boolean.TRUE);
     try {
-      this.logWriter.put(LogWriterLogger.log4jLevelToLogWriterLevel(event.getLevel()),
+      this.logWriter.put(LogLevel.getLogWriterLevel(event.getLevel()),
           event.getMessage().getFormattedMessage(), event.getThrown());
     } finally {
       appending.set(Boolean.FALSE);

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterLogger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterLogger.java b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterLogger.java
index f56599b..2a248cc 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterLogger.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/logging/log4j/LogWriterLogger.java
@@ -105,7 +105,7 @@ public final class LogWriterLogger extends FastLogger implements InternalLogWrit
 
   @Override
   public void setLogWriterLevel(final int logWriterLevel) {
-    setLevel(logWriterLeveltoLog4jLevel(logWriterLevel));
+    setLevel(LogLevel.getLog4jLevel(logWriterLevel));
   }
 
   /**
@@ -1325,103 +1325,11 @@ public final class LogWriterLogger extends FastLogger implements InternalLogWrit
     this.logWrapper.logIfEnabled(this.loggerName, Level.FATAL, null, message, t);
   }
 
-  /************************************************************
-   * Methods to support backwards compatibility between levels.
-   ************************************************************/
-
-  public static Level logWriterLeveltoLog4jLevel(final int logWriterLevel) {
-    switch (logWriterLevel) {
-      case InternalLogWriter.SEVERE_LEVEL:
-        return Level.FATAL;
-      case InternalLogWriter.ERROR_LEVEL:
-        return Level.ERROR;
-      case InternalLogWriter.WARNING_LEVEL:
-        return Level.WARN;
-      case InternalLogWriter.CONFIG_LEVEL:
-        return Level.INFO;
-      case InternalLogWriter.INFO_LEVEL:
-        return Level.INFO;
-      case InternalLogWriter.FINE_LEVEL:
-        return Level.DEBUG;
-      case InternalLogWriter.FINER_LEVEL:
-        return Level.DEBUG;
-      case InternalLogWriter.FINEST_LEVEL:
-        return Level.TRACE;
-      case InternalLogWriter.ALL_LEVEL:
-        return Level.ALL;
-      case InternalLogWriter.NONE_LEVEL:
-        return Level.OFF;
-    }
-
-    throw new IllegalArgumentException("Unknown LogWriter level [" + logWriterLevel + "].");
-  }
-
-  public static Level logWriterNametoLog4jLevel(String levelName) {
-    if ("all".equalsIgnoreCase(levelName)) {
-      return Level.ALL;
-    }
-    if ("finest".equalsIgnoreCase(levelName)) {
-      return Level.TRACE;
-    }
-    if ("finer".equalsIgnoreCase(levelName)) {
-      return Level.DEBUG;
-    }
-    if ("fine".equalsIgnoreCase(levelName)) {
-      return Level.DEBUG;
-    }
-    if ("config".equalsIgnoreCase(levelName)) {
-      return Level.INFO;
-    }
-    if ("info".equalsIgnoreCase(levelName)) {
-      return Level.INFO;
-    }
-    if ("warning".equalsIgnoreCase(levelName)) {
-      return Level.WARN;
-    }
-    if ("error".equalsIgnoreCase(levelName)) {
-      return Level.ERROR;
-    }
-    if ("severe".equalsIgnoreCase(levelName)) {
-      return Level.FATAL;
-    }
-    if ("none".equalsIgnoreCase(levelName)) {
-      return Level.OFF;
-    }
-
-    throw new IllegalArgumentException("Unknown LogWriter level [" + levelName + "].");
-  }
-
-  public static int log4jLevelToLogWriterLevel(final Level log4jLevel) {
-    if (log4jLevel == Level.FATAL) {
-      return InternalLogWriter.SEVERE_LEVEL;
-    } else if (log4jLevel == Level.ERROR) {
-      return InternalLogWriter.ERROR_LEVEL;
-    } else if (log4jLevel == Level.WARN) {
-      return InternalLogWriter.WARNING_LEVEL;
-    } else if (log4jLevel == Level.INFO) {
-      return InternalLogWriter.INFO_LEVEL;
-    } else if (log4jLevel == Level.DEBUG) {
-      return InternalLogWriter.FINE_LEVEL;
-    } else if (log4jLevel == Level.TRACE) {
-      return InternalLogWriter.FINEST_LEVEL;
-    } else if (log4jLevel == Level.ALL) {
-      return InternalLogWriter.ALL_LEVEL;
-    } else if (log4jLevel == Level.OFF) {
-      return InternalLogWriter.NONE_LEVEL;
-    }
-
-    throw new IllegalArgumentException("Unknown Log4J level [" + log4jLevel + "].");
-  }
-
   public void log(int logWriterLevel, final String message, final Throwable t) {
-    Level level = logWriterLeveltoLog4jLevel(logWriterLevel);
+    Level level = LogLevel.getLog4jLevel(logWriterLevel);
     this.logWrapper.logIfEnabled(this.loggerName, level, null, message, t);
   }
 
-  /*****************************************
-   * Methods below are specific to LogWriter
-   *****************************************/
-
   @Override
   public boolean severeEnabled() {
     return isEnabled(Level.FATAL);

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/MemberMessenger.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/MemberMessenger.java b/geode-core/src/main/java/org/apache/geode/management/internal/MemberMessenger.java
index 25366f9..38ffb21 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/MemberMessenger.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/MemberMessenger.java
@@ -15,8 +15,6 @@
 
 package org.apache.geode.management.internal;
 
-import java.util.Set;
-
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.distributed.internal.DM;
 import org.apache.geode.distributed.internal.DistributionManager;
@@ -24,7 +22,9 @@ import org.apache.geode.distributed.internal.DistributionMessage;
 import org.apache.geode.distributed.internal.InternalDistributedSystem;
 import org.apache.geode.distributed.internal.membership.InternalDistributedMember;
 import org.apache.geode.internal.admin.remote.AlertLevelChangeMessage;
-import org.apache.geode.internal.logging.LogWriterImpl;
+import org.apache.geode.internal.logging.log4j.LogLevel;
+
+import java.util.Set;
 
 /**
  * This class will act as a messenger from manager to members for various operations.
@@ -51,7 +51,7 @@ public class MemberMessenger {
   public void sendManagerInfo(DistributedMember receiver) {
 
     String levelName = jmxAdapter.getDistributedSystemMXBean().getAlertLevel();
-    int alertCode = LogWriterImpl.levelNameToCode(levelName);
+    int alertCode = LogLevel.getLogWriterLevel(levelName);
     ManagerStartupMessage msg = ManagerStartupMessage.create(alertCode);
     msg.setRecipient((InternalDistributedMember) receiver);
     sendAsync(msg);
@@ -62,7 +62,7 @@ public class MemberMessenger {
     Set<DistributedMember> otherMemberSet = system.getDistributionManager().getAllOtherMembers();
 
     String levelName = jmxAdapter.getDistributedSystemMXBean().getAlertLevel();
-    int alertCode = LogWriterImpl.levelNameToCode(levelName);
+    int alertCode = LogLevel.getLogWriterLevel(levelName);
     ManagerStartupMessage msg = ManagerStartupMessage.create(alertCode);
     if (otherMemberSet != null && otherMemberSet.size() > 0) {
       msg.setRecipients(otherMemberSet);
@@ -92,7 +92,7 @@ public class MemberMessenger {
    * member of the distributed system.
    */
   public void setAlertLevel(String levelName) {
-    int alertCode = LogWriterImpl.levelNameToCode(levelName);
+    int alertCode = LogLevel.getLogWriterLevel(levelName);
     AlertLevelChangeMessage m = AlertLevelChangeMessage.create(alertCode);
     sendAsync(m);
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
index 8c63382..50c9caa 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ConfigCommands.java
@@ -16,6 +16,7 @@ package org.apache.geode.management.internal.cli.commands;
 
 import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.geode.SystemFailure;
 import org.apache.geode.cache.CacheClosedException;
 import org.apache.geode.cache.execute.FunctionInvocationTargetException;
@@ -41,6 +42,7 @@ import org.apache.geode.management.internal.cli.result.ErrorResultData;
 import org.apache.geode.management.internal.cli.result.InfoResultData;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.configuration.domain.XmlEntity;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
@@ -251,7 +253,8 @@ public class ConfigCommands extends AbstractCommandsSupport {
 
   @CliCommand(value = {CliStrings.ALTER_RUNTIME_CONFIG},
       help = CliStrings.ALTER_RUNTIME_CONFIG__HELP)
-  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_CONFIG},
+      interceptor = "org.apache.geode.management.internal.cli.commands.ConfigCommands$AlterRuntimeInterceptor")
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.MANAGE)
   public Result alterRuntimeConfig(
       @CliOption(key = {CliStrings.ALTER_RUNTIME_CONFIG__MEMBER},
@@ -452,6 +455,20 @@ public class ConfigCommands extends AbstractCommandsSupport {
     }
   }
 
+  public static class AlterRuntimeInterceptor extends AbstractCliAroundInterceptor {
+    @Override
+    public Result preExecution(GfshParseResult parseResult) {
+      Map<String, String> arguments = parseResult.getParamValueStrings();
+      // validate log level
+      String logLevel = arguments.get("log-level");
+      if (!StringUtils.isBlank(logLevel) && (LogLevel.getLevel(logLevel) == null)) {
+        return ResultBuilder.createUserErrorResult("Invalid log level: " + logLevel);
+      }
+
+      return ResultBuilder.createInfoResult("");
+    }
+  }
+
   @CliAvailabilityIndicator({CliStrings.DESCRIBE_CONFIG, CliStrings.EXPORT_CONFIG,
       CliStrings.ALTER_RUNTIME_CONFIG})
   public boolean configCommandsAvailable() {

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
index 428dc33..61b4da7 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/ExportLogsCommand.java
@@ -30,6 +30,7 @@ import org.apache.geode.management.internal.cli.functions.SizeExportLogsFunction
 import org.apache.geode.management.internal.cli.i18n.CliStrings;
 import org.apache.geode.management.internal.cli.result.ResultBuilder;
 import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.configuration.utils.ZipUtils;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission;
@@ -204,8 +205,11 @@ public class ExportLogsCommand implements CommandMarker {
       return 0;
     }
 
-    int sizeLimit = parseSize(fileSizeLimit);
-    int byteMultiplier = parseByteMultiplier(fileSizeLimit);
+      // validate log level
+      String logLevel = arguments.get("log-level");
+      if (StringUtils.isBlank(logLevel) || LogLevel.getLevel(logLevel) == null) {
+        return ResultBuilder.createUserErrorResult("Invalid log level: " + logLevel);
+      }
 
     return sizeLimit * byteMultiplier;
   }

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
index 3ad93ce..313d1bd 100755
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/LauncherLifecycleCommands.java
@@ -58,7 +58,6 @@ import org.apache.geode.internal.GemFireVersion;
 import org.apache.geode.internal.OSProcess;
 import org.apache.geode.internal.cache.persistence.PersistentMemberPattern;
 import org.apache.geode.internal.i18n.LocalizedStrings;
-import org.apache.geode.internal.lang.ClassUtils;
 import org.apache.geode.internal.lang.ObjectUtils;
 import org.apache.geode.internal.lang.StringUtils;
 import org.apache.geode.internal.lang.SystemUtils;
@@ -131,7 +130,6 @@ import java.util.Set;
 import java.util.Stack;
 import java.util.TreeSet;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.Query;

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
index 1fc6027..2a356d8 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/MiscellaneousCommands.java
@@ -14,6 +14,7 @@
  */
 package org.apache.geode.management.internal.cli.commands;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.geode.LogWriter;
 import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheFactory;
@@ -30,7 +31,6 @@ import org.apache.geode.distributed.internal.deadlock.DependencyGraph;
 import org.apache.geode.distributed.internal.deadlock.GemFireDeadlockDetector;
 import org.apache.geode.internal.cache.GemFireCacheImpl;
 import org.apache.geode.internal.logging.LogService;
-import org.apache.geode.internal.logging.LogWriterImpl;
 import org.apache.geode.management.CacheServerMXBean;
 import org.apache.geode.management.DistributedRegionMXBean;
 import org.apache.geode.management.DistributedSystemMXBean;
@@ -70,6 +70,7 @@ import org.apache.geode.management.internal.cli.result.ResultData;
 import org.apache.geode.management.internal.cli.result.ResultDataException;
 import org.apache.geode.management.internal.cli.result.TabularResultData;
 import org.apache.geode.management.internal.cli.shell.Gfsh;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission.Operation;
 import org.apache.geode.security.ResourcePermission.Resource;
@@ -1893,7 +1894,8 @@ public class MiscellaneousCommands implements CommandMarker {
 
 
   @CliCommand(value = CliStrings.CHANGE_LOGLEVEL, help = CliStrings.CHANGE_LOGLEVEL__HELP)
-  @CliMetaData(relatedTopic = {CliStrings.TOPIC_CHANGELOGLEVEL})
+  @CliMetaData(relatedTopic = {CliStrings.TOPIC_CHANGELOGLEVEL},
+      interceptor = "org.apache.geode.management.internal.cli.commands.MiscellaneousCommands$ChangeLogLevelInterceptor")
   @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.WRITE)
   public Result changeLogLevel(
       @CliOption(key = CliStrings.CHANGE_LOGLEVEL__MEMBER, unspecifiedDefaultValue = "",
@@ -1909,28 +1911,9 @@ public class MiscellaneousCommands implements CommandMarker {
             .createUserErrorResult(CliStrings.CHANGE_LOGLEVEL__MSG__SPECIFY_GRP_OR_MEMBER);
       }
 
-      if (logLevel == null || logLevel.length() == 0) {
-        return ResultBuilder
-            .createUserErrorResult(CliStrings.CHANGE_LOGLEVEL__MSG__SPECIFY_LOG_LEVEL);
-      }
-
       Cache cache = GemFireCacheImpl.getInstance();
       LogWriter logger = cache.getLogger();
 
-      boolean validLogLevel = false;
-
-      for (int i = 0; i < LogWriterImpl.allLevels.length - 1; i++) {
-        if (LogWriterImpl.allLevels[i] == LogWriterImpl.levelNameToCode(logLevel)) {
-          validLogLevel = true;
-          break;
-        }
-      }
-
-      if (!validLogLevel) {
-        return ResultBuilder
-            .createUserErrorResult(CliStrings.CHANGE_LOGLEVEL__MSG__INVALID_LOG_LEVEL);
-      }
-
       Set<DistributedMember> dsMembers = new HashSet<DistributedMember>();
       Set<DistributedMember> ds = CliUtil.getAllMembers(cache);
 
@@ -2011,6 +1994,20 @@ public class MiscellaneousCommands implements CommandMarker {
     }
   }
 
+  public static class ChangeLogLevelInterceptor extends AbstractCliAroundInterceptor {
+    @Override
+    public Result preExecution(GfshParseResult parseResult) {
+      Map<String, String> arguments = parseResult.getParamValueStrings();
+      // validate log level
+      String logLevel = arguments.get("loglevel");
+      if (StringUtils.isBlank(logLevel) || LogLevel.getLevel(logLevel) == null) {
+        return ResultBuilder.createUserErrorResult("Invalid log level: " + logLevel);
+      }
+
+      return ResultBuilder.createInfoResult("");
+    }
+  }
+
 
   @CliAvailabilityIndicator({CliStrings.SHUTDOWN, CliStrings.GC, CliStrings.SHOW_DEADLOCK,
       CliStrings.SHOW_METRICS, CliStrings.SHOW_LOG, CliStrings.EXPORT_STACKTRACE,

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
index 39a110c..3a26240 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/converters/LogLevelConverter.java
@@ -14,16 +14,15 @@
  */
 package org.apache.geode.management.internal.cli.converters;
 
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
+import org.apache.geode.management.cli.ConverterHint;
+import org.apache.logging.log4j.Level;
 import org.springframework.shell.core.Completion;
 import org.springframework.shell.core.Converter;
 import org.springframework.shell.core.MethodTarget;
 
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.cli.ConverterHint;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * 
@@ -34,9 +33,9 @@ public class LogLevelConverter implements Converter<String> {
 
   public LogLevelConverter() {
     logLevels = new LinkedHashSet<Completion>();
-    int[] alllevels = LogWriterImpl.allLevels;
-    for (int level : alllevels) {
-      logLevels.add(new Completion(LogWriterImpl.levelToString(level)));
+    Level[] levels = Level.values();
+    for (Level level : levels) {
+      logLevels.add(new Completion(level.name()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
index 99f37cc..91aabe4 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ChangeLogLevelFunction.java
@@ -25,6 +25,7 @@ import org.apache.geode.internal.InternalEntity;
 import org.apache.geode.internal.logging.LogService;
 import org.apache.geode.internal.logging.log4j.LogMarker;
 import org.apache.geode.internal.logging.log4j.LogWriterLogger;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
 
@@ -54,7 +55,7 @@ public class ChangeLogLevelFunction implements Function, InternalEntity {
       LogWriterLogger logwriterLogger = (LogWriterLogger) cache.getLogger();
       Object[] args = (Object[]) context.getArguments();
       final String logLevel = (String) args[0];
-      Level log4jLevel = LogWriterLogger.logWriterNametoLog4jLevel(logLevel);
+      Level log4jLevel = LogLevel.getLevel(logLevel);
       logwriterLogger.setLevel(log4jLevel);
       System.setProperty(DistributionConfig.GEMFIRE_PREFIX + LOG_LEVEL, logLevel);
       // LOG:CONFIG:

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
index 707d88b..13124c5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunction.java
@@ -32,6 +32,7 @@ import org.apache.geode.management.internal.cli.commands.ExportLogsCommand;
 import org.apache.geode.management.internal.cli.util.ExportLogsCacheWriter;
 import org.apache.geode.management.internal.cli.util.LogExporter;
 import org.apache.geode.management.internal.cli.util.LogFilter;
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.geode.management.internal.configuration.domain.Configuration;
 import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.Logger;
@@ -169,7 +170,7 @@ public class ExportLogsFunction implements Function, InternalEntity {
       if (StringUtils.isBlank(logLevel)) {
         this.logLevel = Level.INFO;
       } else {
-        this.logLevel = Level.getLevel(logLevel.toUpperCase());
+        this.logLevel = LogLevel.getLevel(logLevel);
       }
       this.thisLogLevelOnly = logLevelOnly;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
index bbeb5c7..b496249 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/LogLevelExtractor.java
@@ -16,13 +16,11 @@
 
 package org.apache.geode.management.internal.cli.util;
 
+import org.apache.geode.internal.logging.log4j.LogLevel;
 import org.apache.logging.log4j.Level;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -56,7 +54,7 @@ public class LogLevelExtractor {
     private LocalDateTime logTimestamp;
 
     public Result(String logLevel, LocalDateTime logTimestamp) {
-      this.logLevel = LogLevelExtractor.getLevel(logLevel);
+      this.logLevel = LogLevel.resolveLevel(logLevel);
       this.logTimestamp = logTimestamp;
     }
 
@@ -69,26 +67,5 @@ public class LogLevelExtractor {
     }
 
   }
-
-  private static Map<String, Level> LEVELS = new HashMap<>();
-  static {
-    // put all the log4j levels in the map first
-    Arrays.stream(Level.values()).forEach(level -> {
-      LEVELS.put(level.name(), level);
-    });
-    // put all the other levels geode has been using and map them to log4j levels
-    LEVELS.put("SEVERE", Level.FATAL);
-    LEVELS.put("WARNING", Level.WARN);
-    LEVELS.put("CONFIG", Level.DEBUG);
-    LEVELS.put("FINE", Level.DEBUG);
-    LEVELS.put("FINER", Level.TRACE);
-    LEVELS.put("FINEST", Level.TRACE);
-  }
-
-  public static Level getLevel(String level) {
-    Level log4jLevel = LEVELS.get(level.toUpperCase());
-    // make sure any unrecognizable log level is assigned a most specific level
-    return log4jLevel == null ? Level.OFF : log4jLevel;
-  }
 }
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ReadWriteFile.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ReadWriteFile.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ReadWriteFile.java
index 958ed0e..8adac15 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ReadWriteFile.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/ReadWriteFile.java
@@ -14,6 +14,11 @@
  */
 package org.apache.geode.management.internal.cli.util;
 
+import org.apache.geode.cache.execute.FunctionException;
+import org.apache.geode.internal.logging.LogWriterImpl;
+import org.apache.geode.internal.logging.log4j.LogLevel;
+import org.apache.geode.management.internal.cli.GfshParser;
+
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
@@ -27,10 +32,6 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
-import org.apache.geode.cache.execute.FunctionException;
-import org.apache.geode.internal.logging.LogWriterImpl;
-import org.apache.geode.management.internal.cli.GfshParser;
-
 /**
  * 
  * 
@@ -101,7 +102,7 @@ public class ReadWriteFile {
       if (onlyLogLevel.toLowerCase().equals("false")) {
         int[] intLogLevels = LogWriterImpl.allLevels;
         for (int level : intLogLevels) {
-          if (level >= LogWriterImpl.levelNameToCode(logLevel)) {
+          if (level >= LogLevel.getLogWriterLevel(logLevel)) {
             logLevels.add(LogWriterImpl.levelToString(level).toLowerCase());
           }
         }

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
index 0801360..9f6c5fb 100644
--- a/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/distributed/internal/DistributionConfigJUnitTest.java
@@ -14,19 +14,33 @@
  */
 package org.apache.geode.distributed.internal;
 
-import static org.apache.geode.distributed.ConfigurationProperties.*;
-import static org.junit.Assert.*;
+import static org.apache.geode.distributed.ConfigurationProperties.ACK_WAIT_THRESHOLD;
+import static org.apache.geode.distributed.ConfigurationProperties.ARCHIVE_DISK_SPACE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.ARCHIVE_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.CLUSTER_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.HTTP_SERVICE_SSL_ENABLED;
+import static org.apache.geode.distributed.ConfigurationProperties.JMX_MANAGER_HTTP_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_DISK_SPACE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_FILE_SIZE_LIMIT;
+import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
+import static org.apache.geode.distributed.ConfigurationProperties.REDUNDANCY_ZONE;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_LOG_LEVEL;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER;
+import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_POST_PROCESSOR;
+import static org.apache.geode.distributed.ConfigurationProperties.SSL_ENABLED_COMPONENTS;
+import static org.apache.geode.distributed.ConfigurationProperties.START_LOCATOR;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_ARCHIVE_FILE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLE_RATE;
+import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 import org.apache.geode.InternalGemFireException;
 import org.apache.geode.UnmodifiableException;
@@ -39,6 +53,15 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
 @Category({UnitTest.class, MembershipTest.class})
 public class DistributionConfigJUnitTest {
 
@@ -305,6 +328,13 @@ public class DistributionConfigJUnitTest {
   }
 
   @Test
+  public void testLog4jLogLevel() {
+    config.modifiable = true;
+    config.setAttribute(LOG_LEVEL, "fatal", ConfigSource.api());
+    assertEquals(config.getLogLevel(), 1000);
+  }
+
+  @Test
   public void testValidLocatorAddress() {
     String address = "81.240.0.1[7056]";
     config.modifiable = true;

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogLevelTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogLevelTest.java b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogLevelTest.java
new file mode 100644
index 0000000..bc16400
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/internal/logging/log4j/LogLevelTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.internal.logging.log4j;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import org.apache.geode.internal.logging.InternalLogWriter;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(UnitTest.class)
+public class LogLevelTest {
+  @Test
+  public void testGetLevel() {
+    assertThat(LogLevel.getLevel("all")).isEqualTo(Level.ALL);
+    assertThat(LogLevel.getLevel("fatal")).isEqualTo(Level.FATAL);
+    assertThat(LogLevel.getLevel("severe")).isEqualTo(Level.FATAL);
+    assertThat(LogLevel.getLevel("error")).isEqualTo(Level.ERROR);
+    assertThat(LogLevel.getLevel("warn")).isEqualTo(Level.WARN);
+    assertThat(LogLevel.getLevel("warning")).isEqualTo(Level.WARN);
+    assertThat(LogLevel.getLevel("info")).isEqualTo(Level.INFO);
+    assertThat(LogLevel.getLevel("config")).isEqualTo(Level.INFO);
+    assertThat(LogLevel.getLevel("debug")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevel.getLevel("fine")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevel.getLevel("finer")).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.getLevel("finest")).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.getLevel("trace")).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.getLevel("all")).isEqualTo(Level.ALL);
+    assertThat(LogLevel.getLevel("none")).isEqualTo(Level.OFF);
+    assertThat(LogLevel.getLevel("off")).isEqualTo(Level.OFF);
+    assertThat(LogLevel.getLevel("notrecognizable")).isNull();
+  }
+
+  @Test
+  public void testResolveLevel() {
+    assertThat(LogLevel.resolveLevel("all")).isEqualTo(Level.ALL);
+    assertThat(LogLevel.resolveLevel("fatal")).isEqualTo(Level.FATAL);
+    assertThat(LogLevel.resolveLevel("severe")).isEqualTo(Level.FATAL);
+    assertThat(LogLevel.resolveLevel("error")).isEqualTo(Level.ERROR);
+    assertThat(LogLevel.resolveLevel("warn")).isEqualTo(Level.WARN);
+    assertThat(LogLevel.resolveLevel("warning")).isEqualTo(Level.WARN);
+    assertThat(LogLevel.resolveLevel("info")).isEqualTo(Level.INFO);
+    assertThat(LogLevel.resolveLevel("config")).isEqualTo(Level.INFO);
+    assertThat(LogLevel.resolveLevel("debug")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevel.resolveLevel("fine")).isEqualTo(Level.DEBUG);
+    assertThat(LogLevel.resolveLevel("finer")).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.resolveLevel("finest")).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.resolveLevel("trace")).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.resolveLevel("all")).isEqualTo(Level.ALL);
+    assertThat(LogLevel.resolveLevel("none")).isEqualTo(Level.OFF);
+    assertThat(LogLevel.resolveLevel("off")).isEqualTo(Level.OFF);
+    assertThat(LogLevel.resolveLevel("notrecognizable")).isEqualTo(Level.OFF);
+  }
+
+  @Test
+  public void testGetLog4jLevel() throws Exception {
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.SEVERE_LEVEL)).isEqualTo(Level.FATAL);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.ERROR_LEVEL)).isEqualTo(Level.ERROR);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.WARNING_LEVEL)).isEqualTo(Level.WARN);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.CONFIG_LEVEL)).isEqualTo(Level.INFO);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.INFO_LEVEL)).isEqualTo(Level.INFO);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.FINE_LEVEL)).isEqualTo(Level.DEBUG);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.FINER_LEVEL)).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.FINEST_LEVEL)).isEqualTo(Level.TRACE);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.ALL_LEVEL)).isEqualTo(Level.ALL);
+    assertThat(LogLevel.getLog4jLevel(InternalLogWriter.NONE_LEVEL)).isEqualTo(Level.OFF);
+    assertThatThrownBy(() -> LogLevel.getLog4jLevel(123123123))
+        .hasMessageContaining("Unknown LogWriter level");
+  }
+
+  @Test
+  public void testGetLogWriterLevel() throws Exception {
+    assertThat(LogLevel.getLogWriterLevel(Level.FATAL)).isEqualTo(InternalLogWriter.SEVERE_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.ERROR)).isEqualTo(InternalLogWriter.ERROR_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.WARN)).isEqualTo(InternalLogWriter.WARNING_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.INFO)).isEqualTo(InternalLogWriter.INFO_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.DEBUG)).isEqualTo(InternalLogWriter.FINE_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.TRACE)).isEqualTo(InternalLogWriter.FINEST_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.ALL)).isEqualTo(InternalLogWriter.ALL_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel(Level.OFF)).isEqualTo(InternalLogWriter.NONE_LEVEL);
+  }
+
+  @Test
+  public void testGetLogWriterLevelWithString() throws Exception {
+    assertThat(LogLevel.getLogWriterLevel("FATAL")).isEqualTo(InternalLogWriter.SEVERE_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("error")).isEqualTo(InternalLogWriter.ERROR_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("WARN")).isEqualTo(InternalLogWriter.WARNING_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("info")).isEqualTo(InternalLogWriter.INFO_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("CONFIG")).isEqualTo(InternalLogWriter.CONFIG_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("DEBUG")).isEqualTo(InternalLogWriter.FINE_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("trace")).isEqualTo(InternalLogWriter.FINEST_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("ALL")).isEqualTo(InternalLogWriter.ALL_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("none")).isEqualTo(InternalLogWriter.NONE_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("fine")).isEqualTo(InternalLogWriter.FINE_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("finer")).isEqualTo(InternalLogWriter.FINER_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("finest")).isEqualTo(InternalLogWriter.FINEST_LEVEL);
+    assertThat(LogLevel.getLogWriterLevel("level-1234")).isEqualTo(1234);
+    assertThatThrownBy(() -> LogLevel.getLogWriterLevel((String) null))
+        .isExactlyInstanceOf(IllegalArgumentException.class);
+    assertThatThrownBy(() -> LogLevel.getLogWriterLevel("test"))
+        .hasMessageContaining("OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL");
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
index 9709aa6..ec8fdb6 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsInterceptorJUnitTest.java
@@ -54,13 +54,6 @@ public class ExportLogsInterceptorJUnitTest {
   }
 
   @Test
-  public void testLogLevel() {
-    arguments.put("log-level", "test");
-    result = interceptor.preExecution(parseResult);
-    assertThat(result.nextLine()).contains("Invalid log level: test");
-  }
-
-  @Test
   public void testStartEnd() {
     arguments.put("start-time", "2000/01/01");
     arguments.put("end-time", "2000/01/02");

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LogLevelInterceptorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LogLevelInterceptorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LogLevelInterceptorTest.java
new file mode 100644
index 0000000..41b9715
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/LogLevelInterceptorTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.management.internal.cli.commands;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.when;
+
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.AbstractCliAroundInterceptor;
+import org.apache.geode.management.internal.cli.GfshParseResult;
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.mockito.Mockito;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Category(UnitTest.class)
+public class LogLevelInterceptorTest {
+  private List<AbstractCliAroundInterceptor> interceptors = new ArrayList<>();
+  private GfshParseResult parseResult;
+  private Map<String, String> arguments;
+  private Result result;
+
+  @Before
+  public void before() {
+    interceptors.add(new ExportLogCommand.ExportLogsInterceptor());
+    interceptors.add(new ConfigCommands.AlterRuntimeInterceptor());
+    interceptors.add(new MiscellaneousCommands.ChangeLogLevelInterceptor());
+
+    parseResult = Mockito.mock(GfshParseResult.class);
+    arguments = new HashMap<>();
+    when(parseResult.getParamValueStrings()).thenReturn(arguments);
+  }
+
+  @Test
+  public void testInvalidLogLevel() {
+    arguments.put("log-level", "test");
+    arguments.put("loglevel", "test");
+    for (AbstractCliAroundInterceptor interceptor : interceptors) {
+      result = interceptor.preExecution(parseResult);
+      assertThat(result.nextLine()).contains("Invalid log level: test");
+    }
+  }
+
+  @Test
+  public void testGeodeLogLevel() {
+    arguments.put("log-level", "fine");
+    arguments.put("loglevel", "fine");
+    for (AbstractCliAroundInterceptor interceptor : interceptors) {
+      result = interceptor.preExecution(parseResult);
+      assertThat(result.nextLine()).isEmpty();
+    }
+  }
+
+  @Test
+  public void testLog4JLevel() {
+    arguments.put("log-level", "trace");
+    arguments.put("loglevel", "trace");
+    for (AbstractCliAroundInterceptor interceptor : interceptors) {
+      result = interceptor.preExecution(parseResult);
+      assertThat(result.nextLine()).isEmpty();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/management/internal/cli/converters/LogLevelConverterTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/converters/LogLevelConverterTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/converters/LogLevelConverterTest.java
new file mode 100644
index 0000000..44f27d7
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/converters/LogLevelConverterTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.management.internal.cli.converters;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.geode.test.junit.categories.UnitTest;
+import org.apache.logging.log4j.Level;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.springframework.shell.core.Completion;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Category(UnitTest.class)
+public class LogLevelConverterTest {
+
+  @Test
+  public void testCompletionContainsOnlyLog4jLevels() throws Exception {
+    LogLevelConverter converter = new LogLevelConverter();
+    List<Completion> completions = new ArrayList();
+
+    converter.getAllPossibleValues(completions, null, null, null, null);
+
+    assertThat(completions.size()).isEqualTo(8);
+
+    for (Completion completion : completions) {
+      String level = completion.getValue();
+      assertThat(Level.getLevel(level)).isNotNull();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
index cdc5766..d980318 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/functions/ExportLogsFunctionIntegrationTest.java
@@ -117,6 +117,16 @@ public class ExportLogsFunctionIntegrationTest {
     assertThat(args.isIncludeStats()).isFalse();
   }
 
+  @Test
+  public void argsCorrectlyBuiltWithGeodeLevel() {
+    ExportLogsFunction.Args args =
+        new ExportLogsFunction.Args(null, null, "fine", true, true, false);
+    assertThat(args.getLogLevel()).isEqualTo(Level.DEBUG);
+    assertThat(args.isThisLogLevelOnly()).isTrue();
+    assertThat(args.isIncludeLogs()).isTrue();
+    assertThat(args.isIncludeStats()).isFalse();
+  }
+
   private static class CapturingResultSender implements ResultSender {
     private Throwable t;
 

http://git-wip-us.apache.org/repos/asf/geode/blob/f722c516/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
index fd7d68b..9487ba7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/util/LogLevelExtractorTest.java
@@ -93,25 +93,4 @@ public class LogLevelExtractorTest {
 
     assertThat(result).isNull();
   }
-
-  @Test
-  public void testGetLevel() {
-    assertThat(LogLevelExtractor.getLevel("all")).isEqualTo(Level.ALL);
-    assertThat(LogLevelExtractor.getLevel("fatal")).isEqualTo(Level.FATAL);
-    assertThat(LogLevelExtractor.getLevel("severe")).isEqualTo(Level.FATAL);
-    assertThat(LogLevelExtractor.getLevel("error")).isEqualTo(Level.ERROR);
-    assertThat(LogLevelExtractor.getLevel("warn")).isEqualTo(Level.WARN);
-    assertThat(LogLevelExtractor.getLevel("warning")).isEqualTo(Level.WARN);
-    assertThat(LogLevelExtractor.getLevel("info")).isEqualTo(Level.INFO);
-    assertThat(LogLevelExtractor.getLevel("config")).isEqualTo(Level.DEBUG);
-    assertThat(LogLevelExtractor.getLevel("debug")).isEqualTo(Level.DEBUG);
-    assertThat(LogLevelExtractor.getLevel("fine")).isEqualTo(Level.DEBUG);
-    assertThat(LogLevelExtractor.getLevel("finer")).isEqualTo(Level.TRACE);
-    assertThat(LogLevelExtractor.getLevel("finest")).isEqualTo(Level.TRACE);
-    assertThat(LogLevelExtractor.getLevel("all")).isEqualTo(Level.ALL);
-    assertThat(LogLevelExtractor.getLevel("none")).isEqualTo(Level.OFF);
-    assertThat(LogLevelExtractor.getLevel("notrecognizable")).isEqualTo(Level.OFF);
-
-  }
-
 }


Mime
View raw message