You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2024/10/01 08:35:48 UTC

(logging-log4j2) branch 2.x updated (832cadec8b -> 1e3223cfa7)

This is an automated email from the ASF dual-hosted git repository.

vy pushed a change to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


    from 832cadec8b Update `org.mongodb:bson` to version `5.2.0` (#3015)
     new 0721bc7b49 Increase logging verbosity in `SocketAppenderReconnectTest`
     new 1e3223cfa7 Explicitly pass host in `SocketAppenderReconnectTest`

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../core/appender/SocketAppenderReconnectTest.java | 32 +++++++++++++---------
 1 file changed, 19 insertions(+), 13 deletions(-)


(logging-log4j2) 01/02: Increase logging verbosity in `SocketAppenderReconnectTest`

Posted by vy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 0721bc7b49d9b62015a79fb135b9e019c72ec779
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Tue Oct 1 10:23:23 2024 +0200

    Increase logging verbosity in `SocketAppenderReconnectTest`
---
 .../logging/log4j/core/appender/SocketAppenderReconnectTest.java      | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
index 36e33fe5e9..817545af16 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
@@ -344,7 +344,7 @@ public class SocketAppenderReconnectTest {
             throws Exception {
 
         // Report status
-        StatusLogger.getLogger().trace("[{}] verifying logging success", CLASS_NAME);
+        StatusLogger.getLogger().debug("[{}] verifying logging success", CLASS_NAME);
 
         // Create messages to log
         final int messageCount = 2;
@@ -388,7 +388,7 @@ public class SocketAppenderReconnectTest {
             final LoggerContext loggerContext, final BufferingErrorHandler errorHandler) {
 
         // Report status
-        StatusLogger.getLogger().trace("[{}] verifying logging failure", CLASS_NAME);
+        StatusLogger.getLogger().debug("[{}] verifying logging failure", CLASS_NAME);
 
         // Verify the configuration
         final Logger logger = loggerContext.getRootLogger();


(logging-log4j2) 02/02: Explicitly pass host in `SocketAppenderReconnectTest`

Posted by vy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 1e3223cfa7e1a474ae1cc6872a475690bd402c4f
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Tue Oct 1 10:36:28 2024 +0200

    Explicitly pass host in `SocketAppenderReconnectTest`
---
 .../core/appender/SocketAppenderReconnectTest.java | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
index 817545af16..61d6528708 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/SocketAppenderReconnectTest.java
@@ -75,10 +75,11 @@ public class SocketAppenderReconnectTest {
 
             // Start the server.
             server.start("Main", EPHEMERAL_PORT);
-            final int port = server.getServerSocket().getLocalPort();
+            final String serverHost = server.getServerSocket().getInetAddress().getHostAddress();
+            final int serverPort = server.getServerSocket().getLocalPort();
 
             // Initialize the logger context
-            final Configuration config = createConfiguration(port, null);
+            final Configuration config = createConfiguration(serverHost, serverPort, null);
             try (final LoggerContext loggerContext = createStartedLoggerContext(config)) {
 
                 // Configure the error handler
@@ -93,7 +94,7 @@ public class SocketAppenderReconnectTest {
                 verifyLoggingFailure(loggerContext, errorHandler);
 
                 // Start the server again, and verify the logging success.
-                server.start("Main", port);
+                server.start("Main", serverPort);
                 verifyLoggingSuccess(loggerContext, server, errorHandler);
             }
         }
@@ -119,9 +120,9 @@ public class SocketAppenderReconnectTest {
 
                 // Initialize the logger context
                 final Configuration config = createConfiguration(
-                        // Passing an invalid port, since the resolution is supposed to be performed by the mocked host
-                        // resolver anyway.
-                        0, null);
+                        // Passing dummy host & port, since the resolution is supposed to be performed by the mocked
+                        // host resolver anyway.
+                        "localhost", 0, null);
                 try (final LoggerContext loggerContext = createStartedLoggerContext(config)) {
 
                     // Configure the error handler
@@ -213,7 +214,9 @@ public class SocketAppenderReconnectTest {
 
             // Start the 1st server
             server1.start("1st", EPHEMERAL_PORT);
-            final int port = server1.getServerSocket().getLocalPort();
+            final String server1Host =
+                    server1.getServerSocket().getInetAddress().getHostAddress();
+            final int server1Port = server1.getServerSocket().getLocalPort();
 
             // Create the configuration transformer to add the `<Ssl>`, `<KeyStore>`, and `<TrustStore>` elements
             final BiFunction<
@@ -239,7 +242,8 @@ public class SocketAppenderReconnectTest {
                     };
 
             // Initialize the logger context
-            final Configuration config1 = createConfiguration(port, appenderComponentBuilderTransformer);
+            final Configuration config1 =
+                    createConfiguration(server1Host, server1Port, appenderComponentBuilderTransformer);
             try (final LoggerContext loggerContext = createStartedLoggerContext(config1)) {
 
                 // Configure the error handler
@@ -251,7 +255,7 @@ public class SocketAppenderReconnectTest {
 
                 // Stop the 1st server and start the 2nd one (using different SSL configuration!) on the same port
                 server1.close();
-                server2.start("2nd", port);
+                server2.start("2nd", server1Port);
 
                 // Stage the key store files using the 2nd `SSLContext`
                 Files.write(keyStoreFilePath, Files.readAllBytes(Paths.get(keyStore2Location)));
@@ -283,7 +287,8 @@ public class SocketAppenderReconnectTest {
                 //
                 // Hence, the only way is to programmatically build the very same configuration, twice, and use the 1st
                 // one for initialization, and the 2nd one for reconfiguration.
-                final Configuration config2 = createConfiguration(port, appenderComponentBuilderTransformer);
+                final Configuration config2 =
+                        createConfiguration(server1Host, server1Port, appenderComponentBuilderTransformer);
                 loggerContext.reconfigure(config2);
 
                 // Verify the working state on the 2nd server
@@ -293,6 +298,7 @@ public class SocketAppenderReconnectTest {
     }
 
     private static Configuration createConfiguration(
+            final String host,
             final int port,
             @Nullable
                     final BiFunction<
@@ -310,7 +316,7 @@ public class SocketAppenderReconnectTest {
         // Create the appender configuration
         final AppenderComponentBuilder appenderComponentBuilder = configBuilder
                 .newAppender(APPENDER_NAME, "Socket")
-                .addAttribute("host", "localhost")
+                .addAttribute("host", host)
                 .addAttribute("port", port)
                 .addAttribute("ignoreExceptions", false)
                 .addAttribute("reconnectionDelayMillis", 10)