From 244bec0a5b5322be8d97cf41f365a5c09852c6a9 Mon Sep 17 00:00:00 2001 From: John Blum Date: Mon, 13 Sep 2021 15:54:36 -0700 Subject: [PATCH] Cleanup log framework log-levels (set to 'error'). Change default log-level for a Locator to 'warn'. Add logger configuration for 'org.groups". Resolves gh-296. --- .../LocatorApplicationConfiguration.java | 2 +- ...eClusterConfigurationIntegrationTests.java | 19 ++++++++++------- ...tCacheVariableServersIntegrationTests.java | 9 +++++--- ...ableGemFirePropertiesIntegrationTests.java | 7 +------ ...nWithAddedCacheServerIntegrationTests.java | 21 ++++++------------- .../resources/java-util-logging.properties | 1 + .../src/test/resources/log4j2-test.xml | 1 + .../src/test/resources/logback.xml | 4 +++- 8 files changed, 31 insertions(+), 33 deletions(-) diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationConfiguration.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationConfiguration.java index 1f872b9d..ea90cd08 100644 --- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationConfiguration.java +++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/annotation/LocatorApplicationConfiguration.java @@ -66,7 +66,7 @@ public class LocatorApplicationConfiguration extends AbstractAnnotationConfigSup public static final int DEFAULT_PORT = 10334; - public static final String DEFAULT_LOG_LEVEL = "config"; + public static final String DEFAULT_LOG_LEVEL = "warn"; public static final String DEFAULT_NAME = "SpringBasedLocatorApplication"; protected static final String EXCLUSIVE_LOCATOR_APPLICATION_ERROR_MESSAGE = diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheClusterConfigurationIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheClusterConfigurationIntegrationTests.java index 1387f744..084083f5 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheClusterConfigurationIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/CacheClusterConfigurationIntegrationTests.java @@ -55,6 +55,9 @@ import org.springframework.data.gemfire.util.ArrayUtils; import org.springframework.util.FileSystemUtils; import org.springframework.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Integration Tests testing the integration of Spring Data for Apache Geode with Apache Geode's new shared, persistent, * cluster configuration service. @@ -75,9 +78,11 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ private static final List locatorProcessOutput = Collections.synchronizedList(new ArrayList<>()); + private static final Logger logger = LoggerFactory.getLogger(CacheClusterConfigurationIntegrationTests.class); + private static ProcessWrapper locatorProcess; - private static final String LOG_LEVEL = "config"; + private static final String LOG_LEVEL = "error"; private static final String LOG_FILE = "Locator.log"; @Rule @@ -86,10 +91,10 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ @Override protected void failed(Throwable throwable, Description description) { - System.err.printf("Test [%s] failed...%n", description.getDisplayName()); - System.err.println(ThrowableUtils.toString(throwable)); - System.err.println("Locator process log file contents were..."); - System.err.println(getLocatorProcessOutput(description)); + logger.error("Test [%s] failed...{}", description.getDisplayName()); + logger.error(ThrowableUtils.toString(throwable)); + logger.error("Locator process log file contents were..."); + logger.error(getLocatorProcessOutput(description)); } @Override @@ -142,8 +147,8 @@ public class CacheClusterConfigurationIntegrationTests extends ForkingClientServ List arguments = new ArrayList<>(); arguments.add("-Dgemfire.name=" + locatorName); - arguments.add("-Dlog4j.geode.log.level=info"); - arguments.add("-Dlogback.log.level=info"); + arguments.add("-Dlog4j.geode.log.level=error"); + arguments.add("-Dlogback.log.level=error"); arguments.add("-Dspring.data.gemfire.enable-cluster-configuration=true"); arguments.add("-Dspring.data.gemfire.load-cluster-configuration=true"); arguments.add(String.format("-Dgemfire.log-level=%s", LOG_LEVEL)); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java index 9d67db7d..a813497a 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/ClientCacheVariableServersIntegrationTests.java @@ -48,6 +48,9 @@ import org.springframework.data.gemfire.util.CollectionUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Integration Tests testing the use of variable {@literal servers} attribute on <gfe:pool/< in SDG XML Namespace * configuration metadata when connecting a client and server. @@ -66,6 +69,8 @@ import org.springframework.test.context.junit4.SpringRunner; @SuppressWarnings("unused") public class ClientCacheVariableServersIntegrationTests extends ForkingClientServerIntegrationTestsSupport { + private static final Logger logger = LoggerFactory.getLogger(ClientCacheVariableServersIntegrationTests.class); + @BeforeClass public static void startGeodeServer() throws IOException { @@ -143,11 +148,9 @@ public class ClientCacheVariableServersIntegrationTests extends ForkingClientSer CollectionUtils.nullSafeMap(applicationContext.getBeansOfType(CacheServer.class)); for (CacheServer cacheServer : cacheServers.values()) { - System.err.printf("CacheServer host:port [%s:%d]%n", + logger.info("CacheServer host:port [{}:{}]%n", cacheServer.getBindAddress(), cacheServer.getPort()); } - - System.err.flush(); } } } diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java index 1aa7d22d..2ec360d3 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/EnableGemFirePropertiesIntegrationTests.java @@ -285,19 +285,14 @@ public class EnableGemFirePropertiesIntegrationTests extends IntegrationTestsSup assertThat(this.applicationContext.containsBean("gemfireCache")).isTrue(); assertThat(this.applicationContext.containsBean("gemfireProperties")).isTrue(); - Properties gemfireProperties = this.applicationContext.getBean("gemfireProperties", Properties.class); + //Properties gemfireProperties = this.applicationContext.getBean("gemfireProperties", Properties.class); - - // TODO: uncomment when Spring Test for Apache Geode/Pivotal GemFire project replaces - // the test infrastructure classes in SDG. - /* GemFireCache gemfireCache = this.applicationContext.getBean("gemfireCache", GemFireCache.class); assertThat(gemfireCache).isNotNull(); assertThat(gemfireCache.getDistributedSystem()).isNotNull(); Properties gemfireProperties = gemfireCache.getDistributedSystem().getProperties(); - */ assertThat(gemfireProperties).isNotNull(); assertThat(gemfireProperties.containsKey("name")).isTrue(); diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java index daaf1a6c..afc6b7e6 100644 --- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java +++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/config/annotation/PeerCacheApplicationWithAddedCacheServerIntegrationTests.java @@ -18,7 +18,6 @@ package org.springframework.data.gemfire.config.annotation; import static org.assertj.core.api.Assertions.assertThat; import java.util.List; -import java.util.Scanner; import org.junit.AfterClass; import org.junit.Before; @@ -30,7 +29,6 @@ import org.apache.geode.cache.Cache; import org.apache.geode.cache.server.CacheServer; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.data.gemfire.GemFireProperties; import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport; import org.springframework.data.gemfire.tests.process.ProcessWrapper; @@ -62,17 +60,15 @@ public class PeerCacheApplicationWithAddedCacheServerIntegrationTests private static ProcessWrapper gemfireLocator; - private static final String GEMFIRE_LOG_LEVEL = "config"; - @BeforeClass public static void startGemFireLocator() throws Exception { locatorPort = findAvailablePort(); gemfireLocator = run(TestLocatorConfiguration.class, - "-Dspring.data.gemfire.locator.port=" + locatorPort, - String.format("-D%1$s%2$s=%3$s", GemFireProperties.PROPERTY_NAME_PREFIX, - GemFireProperties.ENABLE_CLUSTER_CONFIGURATION.getName(), false)); +"-Dspring.data.gemfire.locator.port=" + locatorPort, + String.format("-D%1$s%2$s=%3$s", GemFireProperties.PROPERTY_NAME_PREFIX, + GemFireProperties.ENABLE_CLUSTER_CONFIGURATION.getName(), false)); waitForServerToStart("localhost", locatorPort); @@ -117,17 +113,12 @@ public class PeerCacheApplicationWithAddedCacheServerIntegrationTests assertThat(cacheServer.getPort()).isEqualTo(cacheServerPort); } - @LocatorApplication(logLevel = GEMFIRE_LOG_LEVEL) + @LocatorApplication static class TestLocatorConfiguration { public static void main(String[] args) { - - AnnotationConfigApplicationContext applicationContext = - new AnnotationConfigApplicationContext(TestLocatorConfiguration.class); - - applicationContext.registerShutdownHook(); - - new Scanner(System.in).nextLine(); + runSpringApplication(TestLocatorConfiguration.class); + block(); } } diff --git a/spring-data-geode/src/test/resources/java-util-logging.properties b/spring-data-geode/src/test/resources/java-util-logging.properties index 37ccf2c3..4373eb05 100644 --- a/spring-data-geode/src/test/resources/java-util-logging.properties +++ b/spring-data-geode/src/test/resources/java-util-logging.properties @@ -1,6 +1,7 @@ # java.util.logging (JUL) configuration org.apache=ERROR +org.jgroups=ERROR org.springframework=ERROR org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter=OFF org.springframework.data.gemfire.listener.adapter.ContinuousQueryListenerAdapter.useParentHandlers=false diff --git a/spring-data-geode/src/test/resources/log4j2-test.xml b/spring-data-geode/src/test/resources/log4j2-test.xml index 6c689d0e..77daaaa0 100644 --- a/spring-data-geode/src/test/resources/log4j2-test.xml +++ b/spring-data-geode/src/test/resources/log4j2-test.xml @@ -10,6 +10,7 @@ + diff --git a/spring-data-geode/src/test/resources/logback.xml b/spring-data-geode/src/test/resources/logback.xml index 84149206..2e562b34 100644 --- a/spring-data-geode/src/test/resources/logback.xml +++ b/spring-data-geode/src/test/resources/logback.xml @@ -21,11 +21,13 @@ + + - +