You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2015/10/16 22:42:30 UTC
[49/50] [abbrv] incubator-geode git commit: GEODE-189: Configure
Log4J 2 using classpath instead of system property
GEODE-189: Configure Log4J 2 using classpath instead of system property
Rename log4j2-default.xml to log4j2.xml. Move log4j2.xml and
log4j2-cli.xml to the root of the gemfire-core JAR file. By default
Log4J 2 will find and use the log4j2.xml in the JAR file unless the
user places a custom config file earlier in the classpath or specifies
the log4j.configurationFile system property.
The new JGroups JAR also contains log4j2.xml in its root, so we need to
ensure that gemfire-core JAR is on the classpath before JGroups.
Upgrade System-Rules JUnit library to 1.12.1.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/21743ec1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/21743ec1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/21743ec1
Branch: refs/heads/feature/GEODE-291
Commit: 21743ec131735cb7c3fd11c6a4ce3e18b79b06f9
Parents: 8d1ada3
Author: Kirk Lund <kl...@pivotal.io>
Authored: Thu Aug 13 11:36:43 2015 -0700
Committer: Kirk Lund <kl...@pivotal.io>
Committed: Wed Oct 14 10:28:46 2015 -0700
----------------------------------------------------------------------
build.gradle | 2 +-
gemfire-assembly/build.gradle | 9 +-
gemfire-assembly/src/main/dist/bin/gfsh | 2 +-
gemfire-assembly/src/main/dist/bin/gfsh.bat | 2 +-
.../gemfire/internal/logging/LogService.java | 128 ++++++++-----------
.../internal/logging/log4j/Configurator.java | 5 +
.../internal/logging/log4j/log4j2-cli.xml | 17 ---
.../internal/logging/log4j/log4j2-default.xml | 21 ---
gemfire-core/src/main/resources/log4j2-cli.xml | 17 +++
gemfire-core/src/main/resources/log4j2.xml | 22 ++++
.../logging/LogServiceIntegrationJUnitTest.java | 98 +++++++-------
.../internal/logging/LogServiceJUnitTest.java | 58 +++++----
.../LogServiceUserDirIntegrationJUnitTest.java | 70 ----------
.../logging/LoggingIntegrationTestSuite.java | 6 +-
.../internal/logging/LoggingUnitTestSuite.java | 15 ++-
.../logging/MergeLogFilesJUnitTest.java | 4 +-
.../log4j/FastLoggerIntegrationJUnitTest.java | 4 +-
.../FastLoggerWithDefaultConfigJUnitTest.java | 4 +-
18 files changed, 208 insertions(+), 276 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index c1534de..f2aa561 100755
--- a/build.gradle
+++ b/build.gradle
@@ -284,7 +284,7 @@ subprojects {
compile 'org.springframework:spring-web:3.2.12.RELEASE'
compile 'org.springframework:spring-webmvc:3.2.12.RELEASE'
- testCompile 'com.github.stefanbirkner:system-rules:1.9.0'
+ testCompile 'com.github.stefanbirkner:system-rules:1.12.1'
testCompile 'edu.umd.cs.mtc:multithreadedtc:1.01'
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:2.1.0'
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-assembly/build.gradle
----------------------------------------------------------------------
diff --git a/gemfire-assembly/build.gradle b/gemfire-assembly/build.gradle
index f65930d..b351729 100755
--- a/gemfire-assembly/build.gradle
+++ b/gemfire-assembly/build.gradle
@@ -154,12 +154,9 @@ distributions {
into ('config') {
from defaultCacheConfig
from defaultDistributionConfig
-
- from (project(':gemfire-core').sourceSets.main.resources.files.find {
- it.name == 'log4j2-default.xml'
- }) {
- rename 'log4j2-default.xml', 'log4j2.xml'
- }
+ from (project(':gemfire-core').sourceSets.main.resources.files.find {
+ it.name == 'log4j2.xml'
+ })
}
into ('lib') {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-assembly/src/main/dist/bin/gfsh
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/main/dist/bin/gfsh b/gemfire-assembly/src/main/dist/bin/gfsh
index e700aae..bcb5a3d 100755
--- a/gemfire-assembly/src/main/dist/bin/gfsh
+++ b/gemfire-assembly/src/main/dist/bin/gfsh
@@ -134,5 +134,5 @@ fi
# This enables job control and monitoring, effectively switching on the trap
# handler to run when the java exe exits, regardless of how (even if killed).
set -bm
-"$GF_JAVA" -Dgfsh=true -Dlog4j.configurationFile=/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml ${JLINE_TERMINAL} -classpath "${CLASSPATH}" $JAVA_ARGS $LAUNCHER "$@"
+"$GF_JAVA" -Dgfsh=true -Dlog4j.configurationFile=classpath:log4j2-cli.xml ${JLINE_TERMINAL} -classpath "${CLASSPATH}" $JAVA_ARGS $LAUNCHER "$@"
exit $?
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-assembly/src/main/dist/bin/gfsh.bat
----------------------------------------------------------------------
diff --git a/gemfire-assembly/src/main/dist/bin/gfsh.bat b/gemfire-assembly/src/main/dist/bin/gfsh.bat
index c4a9480..10c2726 100755
--- a/gemfire-assembly/src/main/dist/bin/gfsh.bat
+++ b/gemfire-assembly/src/main/dist/bin/gfsh.bat
@@ -69,5 +69,5 @@ REM Consider java is from JDK
@if defined JAVA_ARGS (
@set JAVA_ARGS="%JAVA_ARGS%"
)
-@"%GF_JAVA%" -Dgfsh=true -Dlog4j.configurationFile=/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml %JAVA_ARGS% %LAUNCHER% %*
+@"%GF_JAVA%" -Dgfsh=true -Dlog4j.configurationFile=classpath:log4j2-cli.xml %JAVA_ARGS% %LAUNCHER% %*
:done
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
index 637f8ca..a24343c 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/LogService.java
@@ -9,13 +9,28 @@ package com.gemstone.gemfire.internal.logging;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import javax.xml.validation.Validator;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -25,12 +40,27 @@ import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.AppenderRef;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
+import org.apache.logging.log4j.core.config.FileConfigurationMonitor;
import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.config.Node;
+import org.apache.logging.log4j.core.config.status.StatusConfiguration;
+import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
import org.apache.logging.log4j.core.filter.AbstractFilterable;
import org.apache.logging.log4j.core.lookup.Interpolator;
+import org.apache.logging.log4j.core.lookup.StrLookup;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
+import org.apache.logging.log4j.core.util.Closer;
+import org.apache.logging.log4j.core.util.Loader;
+import org.apache.logging.log4j.core.util.Patterns;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.PropertiesUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import com.gemstone.gemfire.InternalGemFireError;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
@@ -66,20 +96,21 @@ public class LogService extends LogManager {
private static final PropertyChangeListener propertyChangeListener = new PropertyChangeListenerImpl();
- public static final String DEFAULT_CONFIG = "/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml";
- public static final String CLI_CONFIG = "/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml";
+ public static final String DEFAULT_CONFIG = "/log4j2.xml";
+ public static final String CLI_CONFIG = "/log4j2-cli.xml";
+ /**
+ * Name of variable that is set to "true" in log4j2.xml to indicate that it is the default gemfire config xml.
+ */
+ private static final String GEMFIRE_DEFAULT_PROPERTY = "gemfire-default";
+
/** Protected by static synchronization. Used for removal and adding stdout back in. */
private static Appender stdoutAppender;
- /** Set with info for Banner to log anytime LogService is reinitialized */
- private static String configFileInformation;
-
static {
init();
}
private static void init() {
- setLog4jConfigFileProperty();
LoggerContext context = ((org.apache.logging.log4j.core.Logger) LogManager.getLogger(BASE_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext();
context.removePropertyChangeListener(propertyChangeListener);
context.addPropertyChangeListener(propertyChangeListener);
@@ -111,83 +142,19 @@ public class LogService extends LogManager {
}
public static boolean isUsingGemFireDefaultConfig() {
- final String configFileName = new StrSubstitutor(new Interpolator()).replace(
- PropertiesUtil.getProperties().getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- return configFileName == null ? false : configFileName.contains(DEFAULT_CONFIG);
- }
-
- /**
- * Check to see if the user has specified a Log4j configuration file. If not, attempt
- * to find a GemFire Log4j configuration file in various locations.
- *
- * @return true if log4j.configurationFile property was set; false if it was unchanged
- */
- private static final boolean setLog4jConfigFileProperty() {
- // fix bug #52175
- final URL configInClasspath = ConfigLocator.findConfigInClasspath();
- if (configInClasspath != null ) {
- // Log4J 2 will find the configuration file in classpath so do nothing
- configFileInformation = "Using log4j configuration found in classpath: '" + configInClasspath.toString() + "'";
- StatusLogger.getLogger().info(configFileInformation);
- return false;
- }
+ final Configuration config = ((org.apache.logging.log4j.core.Logger)
+ LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
- // If the user set the log4j system property then there's nothing else to do.
- final String configFileName = new StrSubstitutor(new Interpolator()).replace(
- PropertiesUtil.getProperties().getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
- if (configFileName != null) {
- final URL configUrl = LogService.class.getResource(configFileName);// log4j2-cli.xml is non-null, external is null
- if (configUrl == null) {
- //We will let log4j2 handle the null case and just log what file we are attempting to use
- configFileInformation = "Using log4j configuration file specified by " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + ": '" + configFileName + "'";
- StatusLogger.getLogger().info(configFileInformation);
- return false;
- }
- else {
- //If the resource can be found and in cases where the resource is in gemfire jar,
- //we set the log location to the file that was found
-
- // must change from Java resource syntax to Java URL syntax (GEODE-232)
- // jar:file:/export/latvia1/users/klund/dev/asf-geode/gemfire-assembly/build/install/apache-geode/lib/gemfire-core-1.0.0-incubating-SNAPSHOT.jar!/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
-
- String configFilePropertyValue = configUrl.toString();
- // configFileName is Java resource syntax, configFilePropertyValue is URL syntax as required by log4j2
-
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFilePropertyValue);
- configFileInformation = "Using log4j configuration file specified by " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + ": '" + configFilePropertyValue + "'";
- StatusLogger.getLogger().info(configFileInformation);
- return true;
- }
- }
+ final StrSubstitutor sub = config.getStrSubstitutor();
+ final StrLookup resolver = sub.getVariableResolver();
-// // set log4j.configurationFactory to be our optimized version
-// final String factory = GemFireXmlConfigurationFactory.class.getName();
-// System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY, factory);
-// StatusLogger.getLogger().debug("Using log4j configuration factory '{}'", factory);
+ final String value = resolver.lookup(GEMFIRE_DEFAULT_PROPERTY);
- // If one of the default log4j config files exists in the current directory then use it.
- File log4jConfigFile = findLog4jConfigInCurrentDir();
- if (log4jConfigFile != null) {
- String filePath = IOUtils.tryGetCanonicalPathElseGetAbsolutePath(log4jConfigFile);
- String value = new File(filePath).toURI().toString();
- String configFilePropertyValue = new File(filePath).toURI().toString();
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFilePropertyValue);
- configFileInformation = "Setting " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + " to specify log4j configuration file in current directory: '" + configFilePropertyValue + "'";
- StatusLogger.getLogger().debug(configFileInformation);
- return true;
- }
-
- // Use the log4j config file found on the classpath in the gemfire jar file.
- final URL configUrl = LogService.class.getResource(DEFAULT_CONFIG);
- String configFilePropertyValue = configUrl.toString();
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFilePropertyValue);
- configFileInformation = "Setting " + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + " to specify log4j configuration file: '" + configFilePropertyValue + "'";
- StatusLogger.getLogger().info(configFileInformation);
- return true;
+ return "true".equals(value);
}
public static String getConfigInformation() {
- return configFileInformation;
+ return getConfiguration().getConfigurationSource().toString();
}
/**
@@ -255,6 +222,12 @@ public class LogService extends LogManager {
return new Throwable().getStackTrace()[depth].getClassName();
}
+ public static Configuration getConfiguration() {
+ final Configuration config = ((org.apache.logging.log4j.core.Logger)
+ LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
+ return config;
+ }
+
public static void configureFastLoggerDelegating() {
final Configuration config = ((org.apache.logging.log4j.core.Logger)
LogManager.getLogger(ROOT_LOGGER_NAME, GemFireParameterizedMessageFactory.INSTANCE)).getContext().getConfiguration();
@@ -300,7 +273,6 @@ public class LogService extends LogManager {
}
public static LoggerConfig getRootLoggerConfig() {
- //return ((org.apache.logging.log4j.core.Logger)LogService.getLogger()).getContext().getConfiguration().getLoggerConfig(LogManager.getRootLogger().getName());
return Configurator.getLoggerConfig(LogManager.getRootLogger().getName());
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
index e07f214..f1509df 100755
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/logging/log4j/Configurator.java
@@ -10,6 +10,7 @@ import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.AppenderRef;
import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.filter.AbstractFilterable;
@@ -125,6 +126,10 @@ public class Configurator {
return config.hasFilter();
}
+ public static String getConfigurationSourceLocation(final Configuration config) {
+ return config.getConfigurationSource().getLocation();
+ }
+
public static boolean hasAppenderFilter(final Configuration config) {
for (Appender appender : config.getAppenders().values()) {
if (appender instanceof AbstractFilterable) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml b/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
deleted file mode 100644
index 14b7075..0000000
--- a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-cli.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
- <Properties>
- <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} <%thread> tid=%tid] %message%n%throwable%n</Property>
- </Properties>
- <Appenders>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="${gemfire-pattern}"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="com.gemstone" level="WARN" additivity="true"/>
- <Root level="WARN">
- <AppenderRef ref="STDOUT"/>
- </Root>
- </Loggers>
-</Configuration>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml b/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
deleted file mode 100644
index a6e8cd8..0000000
--- a/gemfire-core/src/main/resources/com/gemstone/gemfire/internal/logging/log4j/log4j2-default.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
- <Properties>
- <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} <%thread> tid=%tid] %message%n%throwable%n</Property>
- </Properties>
- <Appenders>
- <Console name="STDOUT" target="SYSTEM_OUT">
- <PatternLayout pattern="${gemfire-pattern}"/>
- </Console>
- </Appenders>
- <Loggers>
- <Logger name="com.gemstone" level="INFO" additivity="true">
- <filters>
- <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
- </filters>
- </Logger>
- <Root level="INFO">
- <AppenderRef ref="STDOUT"/>
- </Root>
- </Loggers>
-</Configuration>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/main/resources/log4j2-cli.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/log4j2-cli.xml b/gemfire-core/src/main/resources/log4j2-cli.xml
new file mode 100644
index 0000000..14b7075
--- /dev/null
+++ b/gemfire-core/src/main/resources/log4j2-cli.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
+ <Properties>
+ <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} <%thread> tid=%tid] %message%n%throwable%n</Property>
+ </Properties>
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="${gemfire-pattern}"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="com.gemstone" level="WARN" additivity="true"/>
+ <Root level="WARN">
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/resources/log4j2.xml b/gemfire-core/src/main/resources/log4j2.xml
new file mode 100755
index 0000000..a21a333
--- /dev/null
+++ b/gemfire-core/src/main/resources/log4j2.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j">
+ <Properties>
+ <Property name="gemfire-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} <%thread> tid=%tid] %message%n%throwable%n</Property>
+ <Property name="gemfire-default">true</Property>
+ </Properties>
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="${gemfire-pattern}"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="com.gemstone" level="INFO" additivity="true">
+ <filters>
+ <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
+ </filters>
+ </Logger>
+ <Root level="INFO">
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
index 6425c1f..fb54061 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceIntegrationJUnitTest.java
@@ -7,19 +7,20 @@ import java.io.File;
import java.net.URL;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.status.StatusLogger;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.contrib.java.lang.system.SystemErrRule;
+import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.experimental.categories.Category;
import org.junit.rules.ExternalResource;
import org.junit.rules.TemporaryFolder;
-import com.gemstone.gemfire.internal.ClassPathLoader;
import com.gemstone.gemfire.internal.logging.log4j.Configurator;
import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@@ -31,8 +32,14 @@ import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
@Category(IntegrationTest.class)
public class LogServiceIntegrationJUnitTest {
- private String beforeConfigFileProp;
- private Level beforeLevel;
+ private static final String DEFAULT_CONFIG_FILE_NAME = "log4j2.xml";
+ private static final String CLI_CONFIG_FILE_NAME = "log4j2-cli.xml";
+
+ @Rule
+ public final SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public final SystemOutRule systemOutRule = new SystemOutRule().enableLog();
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -53,6 +60,7 @@ public class LogServiceIntegrationJUnitTest {
protected void after() {
Configurator.shutdown();
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
if (beforeConfigFileProp != null) {
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, beforeConfigFileProp);
}
@@ -63,6 +71,9 @@ public class LogServiceIntegrationJUnitTest {
}
};
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
private URL defaultConfigUrl;
private URL cliConfigUrl;
@@ -72,9 +83,16 @@ public class LogServiceIntegrationJUnitTest {
this.cliConfigUrl = LogService.class.getResource(LogService.CLI_CONFIG);
}
+ @After
+ public void after() {
+ // if either of these fail then log4j2 probably logged a failure to stdout
+ assertThat(this.systemErrRule.getLog()).isEmpty();
+ assertThat(this.systemOutRule.getLog()).isEmpty();
+ }
+
@Test
- public void shouldPreferConfigInConfigurationFilePropertyIfSet() throws Exception {
- final File configFile = this.temporaryFolder.newFile("log4j2.xml");
+ public void shouldPreferConfigurationFilePropertyIfSet() throws Exception {
+ final File configFile = this.temporaryFolder.newFile(DEFAULT_CONFIG_FILE_NAME);
final String configFileName = configFile.toURI().toString();
System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, configFileName);
writeConfigFile(configFile, Level.DEBUG);
@@ -91,21 +109,7 @@ public class LogServiceIntegrationJUnitTest {
LogService.reconfigure();
assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.defaultConfigUrl.toString());
- }
-
- @Test
- public void defaultConfigShouldBeLoadableAsResource() {
- final URL configUrlFromLogService = LogService.class.getResource(LogService.DEFAULT_CONFIG);
- final URL configUrlFromClassLoader = getClass().getClassLoader().getResource(LogService.DEFAULT_CONFIG.substring(1));
- final URL configUrlFromClassPathLoader = ClassPathLoader.getLatest().getResource(LogService.DEFAULT_CONFIG.substring(1));
-
- assertThat(configUrlFromLogService).isNotNull();
- assertThat(configUrlFromClassLoader).isNotNull();
- assertThat(configUrlFromClassPathLoader).isNotNull();
- assertThat(configUrlFromLogService)
- .isEqualTo(configUrlFromClassLoader)
- .isEqualTo(configUrlFromClassPathLoader);
+ assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isNullOrEmpty();
}
@Test
@@ -167,43 +171,37 @@ public class LogServiceIntegrationJUnitTest {
}
@Test
- public void intializeAfterUsingLoggerShouldReconfigure() {
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).as("log4j.configurationFile="+System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isNullOrEmpty();
-
- Configurator.shutdown();
-
- LogManager.getRootLogger();
-
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).as("log4j.configurationFile="+System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isNullOrEmpty();
+ public void shouldNotUseDefaultConfigIfCliConfigSpecified() throws Exception {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.cliConfigUrl.toString());
LogService.reconfigure();
- LogService.initialize();
-
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).as("log4j.configurationFile="+System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).contains(LogService.DEFAULT_CONFIG);
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
- }
- @Test
- public void cliConfigLoadsAsResource() {
- assertThat(this.cliConfigUrl).isNotNull();
- assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+ assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.cliConfigUrl.toString());
+ assertThat(LogService.getLogger().getName()).isEqualTo(getClass().getName());
}
-
+
@Test
- public void defaultConfigLoadsAsResource() {
- assertThat(this.defaultConfigUrl).isNotNull();
- assertThat(this.defaultConfigUrl.toString()).contains(LogService.DEFAULT_CONFIG);
+ public void isUsingGemFireDefaultConfigShouldBeTrueIfDefaultConfig() throws Exception {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.defaultConfigUrl.toString());
+
+ assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains(DEFAULT_CONFIG_FILE_NAME);
+ assertThat(LogService.isUsingGemFireDefaultConfig()).isTrue();
}
-
+
@Test
- public void shouldConvertConfigurationFilePropertyValueToURL() throws Exception {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, LogService.CLI_CONFIG);
+ public void isUsingGemFireDefaultConfigShouldBeFalseIfCliConfig() throws Exception {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.cliConfigUrl.toString());
- LogService.reconfigure();
+ assertThat(LogService.getConfiguration().getConfigurationSource().toString()).doesNotContain(DEFAULT_CONFIG_FILE_NAME);
+ assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+ }
+
+ @Test
+ public void shouldUseCliConfigIfCliConfigIsSpecifiedViaClasspath() throws Exception {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "classpath:"+CLI_CONFIG_FILE_NAME);
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
- assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.cliConfigUrl.toString());
- assertThat(LogService.getLogger().getName()).isEqualTo(getClass().getName());
+ assertThat(LogService.getConfiguration().getConfigurationSource().toString()).contains(CLI_CONFIG_FILE_NAME);
+ assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
index 8d6278a..c8c7eda 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceJUnitTest.java
@@ -3,14 +3,17 @@ package com.gemstone.gemfire.internal.logging;
import static junitparams.JUnitParamsRunner.$;
import static org.assertj.core.api.Assertions.*;
+import java.net.URL;
+
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
+import com.gemstone.gemfire.internal.ClassPathLoader;
import com.gemstone.gemfire.internal.logging.log4j.AppenderContext;
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@@ -29,6 +32,15 @@ public class LogServiceJUnitTest {
@Rule
public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();
+ private URL defaultConfigUrl;
+ private URL cliConfigUrl;
+
+ @Before
+ public void setUp() {
+ this.defaultConfigUrl = LogService.class.getResource(LogService.DEFAULT_CONFIG);
+ this.cliConfigUrl = LogService.class.getResource(LogService.CLI_CONFIG);
+ }
+
@Test
public void getAppenderContextShouldHaveEmptyName() throws Exception {
final AppenderContext appenderContext = LogService.getAppenderContext();
@@ -45,39 +57,37 @@ public class LogServiceJUnitTest {
}
@Test
- public void isUsingGemFireDefaultConfigShouldBeTrueIfDefaultConfig() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, LogService.DEFAULT_CONFIG);
-
- assertThat(LogService.isUsingGemFireDefaultConfig()).isTrue();
+ @Parameters(method = "getToLevelParameters")
+ public void toLevelShouldReturnMatchingLog4jLevel(final int intLevel, final Level level) {
+ assertThat(LogService.toLevel(intLevel)).isSameAs(level);
}
@Test
- public void isUsingGemFireDefaultConfigShouldBeFalseIfEmpty() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "");
-
- assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+ public void cliConfigLoadsAsResource() {
+ assertThat(this.cliConfigUrl).isNotNull();
+ assertThat(this.cliConfigUrl.toString()).contains(LogService.CLI_CONFIG);
}
-
+
@Test
- public void isUsingGemFireDefaultConfigShouldBeFalseIfNull() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "");
-
- assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+ public void defaultConfigLoadsAsResource() {
+ assertThat(this.defaultConfigUrl).isNotNull();
+ assertThat(this.defaultConfigUrl.toString()).contains(LogService.DEFAULT_CONFIG);
}
-
+
@Test
- public void isUsingGemFireDefaultConfigShouldBeFalseIfCliConfig() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, LogService.CLI_CONFIG);
+ public void defaultConfigShouldBeLoadableAsResource() {
+ final URL configUrlFromLogService = LogService.class.getResource(LogService.DEFAULT_CONFIG);
+ final URL configUrlFromClassLoader = getClass().getClassLoader().getResource(LogService.DEFAULT_CONFIG.substring(1));
+ final URL configUrlFromClassPathLoader = ClassPathLoader.getLatest().getResource(LogService.DEFAULT_CONFIG.substring(1));
- assertThat(LogService.isUsingGemFireDefaultConfig()).isFalse();
+ assertThat(configUrlFromLogService).isNotNull();
+ assertThat(configUrlFromClassLoader).isNotNull();
+ assertThat(configUrlFromClassPathLoader).isNotNull();
+ assertThat(configUrlFromLogService)
+ .isEqualTo(configUrlFromClassLoader)
+ .isEqualTo(configUrlFromClassPathLoader);
}
- @Test
- @Parameters(method = "getToLevelParameters")
- public void toLevelShouldReturnMatchingLog4jLevel(final int intLevel, final Level level) {
- assertThat(LogService.toLevel(intLevel)).isSameAs(level);
- }
-
@SuppressWarnings("unused")
private static final Object[] getToLevelParameters() {
return $(
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
deleted file mode 100755
index 4d83c22..0000000
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LogServiceUserDirIntegrationJUnitTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package com.gemstone.gemfire.internal.logging;
-
-import static com.gemstone.gemfire.internal.logging.LogServiceIntegrationTestSupport.*;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assume.assumeFalse;
-
-import java.io.File;
-import java.net.MalformedURLException;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.contrib.java.lang.system.ClearSystemProperties;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.ExternalResource;
-
-import com.gemstone.gemfire.internal.lang.SystemUtils;
-import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-
-/**
- * Tests LogService when a log4j2 config file is in the user.dir
- *
- * @author Kirk Lund
- */
-@Category(IntegrationTest.class)
-public class LogServiceUserDirIntegrationJUnitTest {
-
- @Rule
- public final ClearSystemProperties clearConfigFileProperty = new ClearSystemProperties(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
-
- @Rule
- public final ExternalResource externalResource = new ExternalResource() {
- @Override
- protected void after() {
- LogService.reconfigure();
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
- }
- };
-
- private File configFile;
-
- @Before
- public void setUp() throws Exception {
- this.configFile = new File(System.getProperty("user.dir"), "log4j2-test.xml");
- writeConfigFile(this.configFile, Level.DEBUG);
- LogService.reconfigure();
- }
-
- @After
- public void tearDown() {
- this.configFile.delete();
- }
-
- @Test
- public void shouldPreferConfigInCurrentDirectoryIfFound() throws Exception {
- // if working directory is in classpath this test will fail
- assumeFalse(isUserDirInClassPath());
-
- assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
- //ConfigurationFactory.getInstance().getConfiguration(null, null); TODO: delete
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY)).isEqualTo(this.configFile.toURI().toString());
- }
-
- private static boolean isUserDirInClassPath() throws MalformedURLException {
- return SystemUtils.isInClassPath(System.getProperty("user.dir"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
index dd9504b..cee05c3 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingIntegrationTestSuite.java
@@ -3,13 +3,17 @@ package com.gemstone.gemfire.internal.logging;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+import com.gemstone.gemfire.internal.logging.log4j.FastLoggerIntegrationJUnitTest;
+import com.gemstone.gemfire.internal.logging.log4j.FastLoggerWithDefaultConfigJUnitTest;
+
@RunWith(Suite.class)
@Suite.SuiteClasses({
DistributedSystemLogFileJUnitTest.class,
LocatorLogFileJUnitTest.class,
LogServiceIntegrationJUnitTest.class,
- LogServiceUserDirIntegrationJUnitTest.class,
MergeLogFilesJUnitTest.class,
+ FastLoggerWithDefaultConfigJUnitTest.class,
+ FastLoggerIntegrationJUnitTest.class,
})
public class LoggingIntegrationTestSuite {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingUnitTestSuite.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingUnitTestSuite.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingUnitTestSuite.java
index 6b7b73e..ec3e04a 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingUnitTestSuite.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/LoggingUnitTestSuite.java
@@ -3,11 +3,24 @@ package com.gemstone.gemfire.internal.logging;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
+import com.gemstone.gemfire.internal.logging.log4j.AlertAppenderJUnitTest;
+import com.gemstone.gemfire.internal.logging.log4j.ConfigLocatorJUnitTest;
+import com.gemstone.gemfire.internal.logging.log4j.FastLoggerJUnitTest;
+import com.gemstone.gemfire.internal.logging.log4j.FastLoggerWithDefaultConfigJUnitTest;
+import com.gemstone.gemfire.internal.logging.log4j.LocalizedMessageJUnitTest;
+import com.gemstone.gemfire.internal.logging.log4j.LogWriterAppenderJUnitTest;
+
@RunWith(Suite.class)
@Suite.SuiteClasses({
LogServiceJUnitTest.class,
LogWriterImplJUnitTest.class,
- SortLogFileJUnitTest.class
+ SortLogFileJUnitTest.class,
+ AlertAppenderJUnitTest.class,
+ ConfigLocatorJUnitTest.class,
+ FastLoggerJUnitTest.class,
+ FastLoggerWithDefaultConfigJUnitTest.class,
+ LocalizedMessageJUnitTest.class,
+ LogWriterAppenderJUnitTest.class,
})
public class LoggingUnitTestSuite {
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
index d8d774c..37ba6c2 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/MergeLogFilesJUnitTest.java
@@ -90,7 +90,7 @@ public class MergeLogFilesJUnitTest {
PrintWriter pw = new PrintWriter(sw, true);
MergeLogFiles.mergeLogFiles(streams, names, pw);
- System.out.println(sw.toString());
+ //System.out.println(sw.toString());
// Verfiy that the entries are sorted
BufferedReader br =
@@ -222,7 +222,7 @@ public class MergeLogFilesJUnitTest {
}
}
- System.out.println(baos.toString());
+ //System.out.println(baos.toString());
in = new ByteArrayInputStream(baos.toByteArray());
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
index f1c7ab9..c20b6a7 100644
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerIntegrationJUnitTest.java
@@ -47,6 +47,7 @@ public class FastLoggerIntegrationJUnitTest {
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
private File configFile;
+ private String configFileLocation;
private Logger logger;
private LoggerContext appenderContext;
private Marker enabledMarker;
@@ -56,6 +57,7 @@ public class FastLoggerIntegrationJUnitTest {
public void setUp() throws Exception {
System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
this.configFile = new File(this.temporaryFolder.getRoot(), "log4j2-test.xml");
+ this.configFileLocation = this.configFile.toURI().toURL().toString();
this.enabledMarker = MarkerManager.getMarker(ENABLED_MARKER_NAME);
this.unusedMarker = MarkerManager.getMarker(UNUSED_MARKER_NAME);
setUpLogService();
@@ -70,7 +72,7 @@ public class FastLoggerIntegrationJUnitTest {
private void setUpLogService() throws Exception {
// Load a base config and do some sanity checks
writeSimpleConfigFile(this.configFile, Level.WARN);
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.configFile.toURI().toURL().toString());
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.configFileLocation);
LogService.reconfigure();
LogService.getLogger().getName(); // This causes the config file to be loaded
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/21743ec1/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerWithDefaultConfigJUnitTest.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerWithDefaultConfigJUnitTest.java b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerWithDefaultConfigJUnitTest.java
index 2e08500..7069d20 100755
--- a/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerWithDefaultConfigJUnitTest.java
+++ b/gemfire-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/FastLoggerWithDefaultConfigJUnitTest.java
@@ -1,6 +1,6 @@
package com.gemstone.gemfire.internal.logging.log4j;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.apache.logging.log4j.Logger;
@@ -41,7 +41,7 @@ public class FastLoggerWithDefaultConfigJUnitTest {
*/
@Test
public void configurationFilePropertyIsDefaultConfig() {
- assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY), containsString(LogService.DEFAULT_CONFIG));
+ assertThat(System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY), isEmptyOrNullString());
}
/**