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 2016/04/21 22:50:19 UTC
incubator-geode git commit: Temporary tests to narrow in on why
log4j2.xml is ignored
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-1255 9d92cf586 -> afe7b0953
Temporary tests to narrow in on why log4j2.xml is ignored
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/afe7b095
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/afe7b095
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/afe7b095
Branch: refs/heads/feature/GEODE-1255
Commit: afe7b09532ed79fc902fd9aa72db3541ee80062c
Parents: 9d92cf5
Author: Kirk Lund <kl...@apache.org>
Authored: Thu Apr 21 13:49:02 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Thu Apr 21 13:49:02 2016 -0700
----------------------------------------------------------------------
.../LocatorLauncherRemoteJUnitTest.java | 72 ++++++++++
.../logging/log4j/custom/BasicAppender.java | 72 ++++++++++
...ustom_log4j2_custom_xml_IntegrationTest.java | 140 ++++++++++++++++++
.../Custom_log4j2_xml_IntegrationTest.java | 139 ++++++++++++++++++
...om_log4j2_xml_MinimalistIntegrationTest.java | 127 ++++++++++++++++
..._xml_MinimalistWithCacheIntegrationTest.java | 133 +++++++++++++++++
...alistWithLocatorLauncherIntegrationTest.java | 140 ++++++++++++++++++
...ithLocatorLauncherRemoteIntegrationTest.java | 140 ++++++++++++++++++
...malistWithServerLauncherIntegrationTest.java | 143 +++++++++++++++++++
.../logging/log4j/custom/log4j2-custom.xml | 27 ++++
.../internal/logging/log4j/custom/log4j2.xml | 27 ++++
11 files changed, 1160 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
index 52ebe24..0b237c1 100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorLauncherRemoteJUnitTest.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -42,6 +43,7 @@ import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.DistributionLocator;
import com.gemstone.gemfire.internal.GemFireVersion;
import com.gemstone.gemfire.internal.SocketCreator;
+import com.gemstone.gemfire.internal.lang.StringUtils;
import com.gemstone.gemfire.internal.logging.InternalLogWriter;
import com.gemstone.gemfire.internal.logging.LocalLogWriter;
import com.gemstone.gemfire.internal.process.ProcessControllerFactory;
@@ -202,6 +204,76 @@ public class LocatorLauncherRemoteJUnitTest extends AbstractLocatorLauncherJUnit
}
}
+ private static class ToSystemOut implements ProcessStreamReader.InputListener {
+ @Override
+ public void notifyInputLine(String line) {
+ System.out.println(line);
+ }
+ }
+
+ @Test
+ public void testStartUsesCustomLoggingConfiguration() throws Throwable {
+ // build and start the locator
+ final List<String> jvmArguments = getJvmArguments();
+
+ final List<String> command = new ArrayList<String>();
+ command.add(new File(new File(System.getProperty("java.home"), "bin"), "java").getCanonicalPath());
+ for (String jvmArgument : jvmArguments) {
+ command.add(jvmArgument);
+ }
+ command.add("-D" + ConfigurationFactory.CONFIGURATION_FILE_PROPERTY + "/Users/klund/dev/gemfire/open/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml");
+ command.add("-cp");
+ command.add(System.getProperty("java.class.path"));
+ command.add(LocatorLauncher.class.getName());
+ command.add(LocatorLauncher.Command.START.getName());
+ command.add(getUniqueName());
+ command.add("--port=" + this.locatorPort);
+ command.add("--redirect-output");
+
+ for (String line : command) {
+ System.out.println("KIRK: " + line);
+ }
+
+ this.process = new ProcessBuilder(command).directory(this.temporaryFolder.getRoot()).start();
+ this.processOutReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getInputStream()).inputListener(new ToSystemOut()).build().start();
+ this.processErrReader = new ProcessStreamReader.Builder(this.process).inputStream(this.process.getErrorStream()).inputListener(new ToSystemOut()).build().start();
+
+ int pid = 0;
+ String workingDirectory = this.temporaryFolder.getRoot().getCanonicalPath();
+ System.out.println("KIRK: workingDirectory=" + workingDirectory);
+ this.launcher = new LocatorLauncher.Builder()
+ .setWorkingDirectory(workingDirectory)
+ .build();
+ try {
+ waitForLocatorToStart(this.launcher);
+
+ // validate the pid file and its contents
+ this.pidFile = new File(this.temporaryFolder.getRoot(), ProcessType.LOCATOR.getPidFileName());
+ assertTrue(this.pidFile.exists());
+ pid = readPid(this.pidFile);
+ assertTrue(pid > 0);
+ assertTrue(ProcessUtils.isProcessAlive(pid));
+
+ final String logFileName = getUniqueName()+".log";
+ assertTrue("Log file should exist: " + logFileName, new File(this.temporaryFolder.getRoot(), logFileName).exists());
+
+ // check the status
+ final LocatorState locatorState = this.launcher.status();
+ assertNotNull(locatorState);
+ assertEquals(Status.ONLINE, locatorState.getStatus());
+ } catch (Throwable e) {
+ this.errorCollector.addError(e);
+ }
+
+ // stop the locator
+ try {
+ assertEquals(Status.STOPPED, this.launcher.stop().getStatus());
+ waitForPidToStop(pid);
+ } catch (Throwable e) {
+ this.errorCollector.addError(e);
+ }
+ }
+
@Test
public void testStartDeletesStaleControlFiles() throws Throwable {
// create existing control files
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
new file mode 100644
index 0000000..7783931
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/BasicAppender.java
@@ -0,0 +1,72 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.appender.AbstractAppender;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.layout.PatternLayout;
+
+@Plugin(name = "Basic", category = "Core", elementType = "appender", printObject = true)
+public class BasicAppender extends AbstractAppender {
+
+ private static volatile BasicAppender instance;
+
+ private final List<LogEvent> events = new ArrayList<>();
+
+ public BasicAppender(final String name, final Filter filter, final Layout<? extends Serializable> layout) {
+ super(name, filter, layout);
+ }
+
+ @PluginFactory
+ public static BasicAppender createAppender(@PluginAttribute("name") String name,
+ @PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
+ @PluginElement("Layout") Layout layout,
+ @PluginElement("Filters") Filter filter) {
+ if (layout == null) {
+ layout = PatternLayout.createDefaultLayout();
+ }
+ instance = new BasicAppender(name, filter, layout);
+ return instance;
+ }
+
+ public static BasicAppender getInstance() {
+ return instance;
+ }
+
+ public static void clearInstance() {
+ instance = null;
+ }
+
+ @Override
+ public void append(final LogEvent event) {
+ this.events.add(event);
+ }
+
+ public List<LogEvent> events() {
+ return this.events;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java
new file mode 100644
index 0000000..314d028
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_custom_xml_IntegrationTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_custom_xml_IntegrationTest {
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2-custom.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ Configurator.shutdown();
+ BasicAppender.clearInstance();
+
+ this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ this.beforeLevel = StatusLogger.getLogger().getLevel();
+
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Configurator.shutdown();
+
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ if (this.beforeConfigFileProp != null) {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
+ }
+ StatusLogger.getLogger().setLevel(this.beforeLevel);
+
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
+
+ BasicAppender.clearInstance();
+
+ //assertThat(this.systemErrRule.getLog()).isEmpty();
+ //assertThat(this.systemOutRule.getLog()).isEmpty();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+ assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+ assertThat(event.getLoggerName()).isEqualTo(logLogger);
+ assertThat(event.getLevel()).isEqualTo(logLevel);
+ assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+
+ assertThat(systemOut).contains(logLevel.name());
+ assertThat(systemOut).contains(logMessage);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java
new file mode 100644
index 0000000..b749c13
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_IntegrationTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_xml_IntegrationTest {
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ Configurator.shutdown();
+ BasicAppender.clearInstance();
+
+ this.beforeConfigFileProp = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ this.beforeLevel = StatusLogger.getLogger().getLevel();
+
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ Configurator.shutdown();
+
+ System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ if (this.beforeConfigFileProp != null) {
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, this.beforeConfigFileProp);
+ }
+ StatusLogger.getLogger().setLevel(this.beforeLevel);
+
+ LogService.reconfigure();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isTrue();
+
+ BasicAppender.clearInstance();
+
+ //assertThat(this.systemErrRule.getLog()).isEmpty();
+ //assertThat(this.systemOutRule.getLog()).isEmpty();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+ assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+ assertThat(event.getLoggerName()).isEqualTo(logLogger);
+ assertThat(event.getLevel()).isEqualTo(logLevel);
+ assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+
+ assertThat(systemOut).contains(logLevel.name());
+ assertThat(systemOut).contains(logMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java
new file mode 100644
index 0000000..1d9d87f
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistIntegrationTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.distributed.ServerLauncher;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_xml_MinimalistIntegrationTest {
+
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+
+ //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ BasicAppender.clearInstance();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+ assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+ assertThat(event.getLoggerName()).isEqualTo(logLogger);
+ assertThat(event.getLevel()).isEqualTo(logLevel);
+ assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+
+ assertThat(systemOut).contains(logLevel.name());
+ assertThat(systemOut).contains(logMessage);
+ }
+
+ public void bar() {
+ new ServerLauncher.Builder().setMemberName("Kirk").set("locators", "").build().start();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java
new file mode 100644
index 0000000..05b3dc0
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithCacheIntegrationTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_xml_MinimalistWithCacheIntegrationTest {
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+
+ //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ BasicAppender.clearInstance();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.put(DistributionConfig.LOCATORS_NAME, "");
+ gemfireProperties.put(DistributionConfig.MCAST_PORT_NAME, "0");
+ gemfireProperties.put(DistributionConfig.LOG_LEVEL_NAME, "info");
+ Cache cache = new CacheFactory(gemfireProperties).create();
+
+ cache.getLogger().info("hey kirk");
+
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+// assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+// assertThat(event.getLoggerName()).isEqualTo(logLogger);
+// assertThat(event.getLevel()).isEqualTo(logLevel);
+// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+//
+// assertThat(systemOut).contains(logLevel.name());
+// assertThat(systemOut).contains(logMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java
new file mode 100644
index 0000000..e3a6428
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.LocatorLauncher;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_xml_MinimalistWithLocatorLauncherIntegrationTest {
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+
+ //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+
+ System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(0));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ BasicAppender.clearInstance();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ LocatorLauncher launcher = new LocatorLauncher.Builder()
+ .setCommand(LocatorLauncher.Command.START)
+ .set(DistributionConfig.LOCATORS_NAME, "")
+ .set(DistributionConfig.MCAST_PORT_NAME, "0")
+ .setMemberName("membername")
+ .setPort(AvailablePort.getRandomAvailablePort(AvailablePort.MULTICAST))
+ .build();
+
+ launcher.start();
+
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+// assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+// assertThat(event.getLoggerName()).isEqualTo(logLogger);
+// assertThat(event.getLevel()).isEqualTo(logLevel);
+// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+//
+// assertThat(systemOut).contains(logLevel.name());
+// assertThat(systemOut).contains(logMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java
new file mode 100644
index 0000000..19c8162
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.LocatorLauncher;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_xml_MinimalistWithLocatorLauncherRemoteIntegrationTest {
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+
+ //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+
+ System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(0));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ BasicAppender.clearInstance();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ LocatorLauncher launcher = new LocatorLauncher.Builder()
+ .setCommand(LocatorLauncher.Command.START)
+ .set(DistributionConfig.LOCATORS_NAME, "")
+ .set(DistributionConfig.MCAST_PORT_NAME, "0")
+ .setMemberName("membername")
+ .setPort(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET))
+ .build();
+
+ launcher.start();
+
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+// assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+// assertThat(event.getLoggerName()).isEqualTo(logLogger);
+// assertThat(event.getLevel()).isEqualTo(logLevel);
+// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+//
+// assertThat(systemOut).contains(logLevel.name());
+// assertThat(systemOut).contains(logMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java
new file mode 100644
index 0000000..53b5d2b
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/logging/log4j/custom/Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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 com.gemstone.gemfire.internal.logging.log4j.custom;
+
+import static org.assertj.core.api.Assertions.*;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LogEvent;
+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.RestoreSystemProperties;
+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.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.distributed.ServerLauncher;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.cache.AbstractCacheServer;
+import com.gemstone.gemfire.internal.logging.LogService;
+import com.gemstone.gemfire.internal.logging.log4j.Configurator;
+import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
+
+/**
+ * Integration tests with custom log4j2 configuration.
+ */
+@Category(IntegrationTest.class)
+public class Custom_log4j2_xml_MinimalistWithServerLauncherIntegrationTest {
+
+ private static final String CUSTOM_CONFIG_FILE_NAME = "log4j2.xml";
+
+ @Rule
+ public SystemErrRule systemErrRule = new SystemErrRule().enableLog();
+
+ @Rule
+ public SystemOutRule systemOutRule = new SystemOutRule().enableLog();
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ private String beforeConfigFileProp;
+ private Level beforeLevel;
+
+ private File customConfigFile;
+
+ @Before
+ public void setUp() throws Exception {
+ URL customConfigResource = getClass().getResource(CUSTOM_CONFIG_FILE_NAME);
+ File temporaryFile = this.temporaryFolder.newFile(CUSTOM_CONFIG_FILE_NAME);
+
+ IOUtils.copy(customConfigResource.openStream(), new FileOutputStream(temporaryFile));
+ assertThat(temporaryFile).hasSameContentAs(new File(customConfigResource.toURI()));
+
+ System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, temporaryFile.getAbsolutePath());
+
+ //assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ this.customConfigFile = temporaryFile;
+
+ System.setProperty(AbstractCacheServer.TEST_OVERRIDE_DEFAULT_PORT_PROPERTY, String.valueOf(0));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ BasicAppender.clearInstance();
+ }
+
+ @Test
+ public void foo() throws Exception {
+ Properties gemfireProperties = new Properties();
+ gemfireProperties.put(DistributionConfig.LOCATORS_NAME, "");
+ gemfireProperties.put(DistributionConfig.MCAST_PORT_NAME, "0");
+ gemfireProperties.put(DistributionConfig.LOG_LEVEL_NAME, "info");
+
+ ServerLauncher launcher = new ServerLauncher.Builder()
+ .setCommand(ServerLauncher.Command.START)
+ .set(DistributionConfig.LOCATORS_NAME, "")
+ .set(DistributionConfig.MCAST_PORT_NAME, "0")
+ .setMemberName("membername")
+ .build();
+
+ launcher.start();
+
+ String logLogger = getClass().getName();
+ Level logLevel = Level.DEBUG;
+ String logMessage = "this is a log statement";
+
+ Logger logger = LogService.getLogger();
+ assertThat(LogService.isUsingGemFireDefaultConfig()).as(LogService.getConfigInformation()).isFalse();
+
+ logger.debug(logMessage);
+
+ String systemOut = systemOutRule.getLog();
+ String systemErr = systemErrRule.getLog();
+
+ System.out.println("this.customConfigFile=" + this.customConfigFile);
+ System.out.println("BasicAppender=" + BasicAppender.getInstance());
+ System.out.println("CONFIGURATION_FILE_PROPERTY=" + System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY));
+ System.out.println("out=" + systemOut.trim());
+
+ BasicAppender appender = BasicAppender.getInstance();
+ assertThat(appender).isNotNull();
+// assertThat(appender.events()).hasSize(1);
+
+ LogEvent event = appender.events().get(0);
+ System.out.println("event=" + event);
+
+// assertThat(event.getLoggerName()).isEqualTo(logLogger);
+// assertThat(event.getLevel()).isEqualTo(logLevel);
+// assertThat(event.getMessage().getFormattedMessage()).isEqualTo(logMessage);
+//
+// assertThat(systemOut).contains(logLevel.name());
+// assertThat(systemOut).contains(logMessage);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
new file mode 100644
index 0000000..27a9757
--- /dev/null
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2-custom.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="%level %date{yyyy/MM/dd HH:mm:ss.SSS z} %message%n %throwable%n"/>
+ </Console>
+ <!--Appender type="Basic" name="CUSTOM">
+ <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
+ </Appender-->
+ <Basic name="CUSTOM">
+ <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
+ </Basic>
+ </Appenders>
+ <Loggers>
+ <Logger name="com.gemstone" level="INFO" additivity="true">
+ <filters>
+ <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
+ </filters>
+ </Logger>
+ <Logger name="org.jgroups" level="FATAL" additivity="true"/>
+ <Logger name="com.gemstone.gemfire.internal.logging.log4j.custom" level="DEBUG" additivity="true"/>
+ <Root level="INFO">
+ <AppenderRef ref="CUSTOM"/>
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/afe7b095/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
new file mode 100644
index 0000000..27a9757
--- /dev/null
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/internal/logging/log4j/custom/log4j2.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="FATAL" shutdownHook="disable" packages="com.gemstone.gemfire.internal.logging.log4j.custom">
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="%level %date{yyyy/MM/dd HH:mm:ss.SSS z} %message%n %throwable%n"/>
+ </Console>
+ <!--Appender type="Basic" name="CUSTOM">
+ <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
+ </Appender-->
+ <Basic name="CUSTOM">
+ <PatternLayout pattern="level=%level time=%date{yyyy/MM/dd HH:mm:ss.SSS z} message=%message%n throwable=%throwable%n"/>
+ </Basic>
+ </Appenders>
+ <Loggers>
+ <Logger name="com.gemstone" level="INFO" additivity="true">
+ <filters>
+ <MarkerFilter marker="GEMFIRE_VERBOSE" onMatch="DENY" onMismatch="NEUTRAL"/>
+ </filters>
+ </Logger>
+ <Logger name="org.jgroups" level="FATAL" additivity="true"/>
+ <Logger name="com.gemstone.gemfire.internal.logging.log4j.custom" level="DEBUG" additivity="true"/>
+ <Root level="INFO">
+ <AppenderRef ref="CUSTOM"/>
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>