rbri opened a new issue, #1865:
URL: https://github.com/apache/logging-log4j2/issues/1865

   ## Description
   
   As part of the HtmlUnit (https://github.com/HtmlUnit/htmlunit) project i 
have a lot of test cases doing detailed and sometimes strange things to test 
some functionality.
   In this special case i temporary add an appender to check if something 
happen on the wire.
   
   The code looks like this:
   
           final Logger logger = (Logger) 
LogManager.getLogger("org.apache.http.headers");
           final Level oldLevel = logger.getLevel();
           Configurator.setLevel(logger.getName(), Level.DEBUG);
   
           final StringWriter stringWriter = new StringWriter();
           final PatternLayout layout = 
PatternLayout.newBuilder().withPattern("%msg%n").build();
   
           final WriterAppender writerAppender = 
WriterAppender.newBuilder().setName("writeLogger").setTarget(stringWriter)
                   .setLayout(layout).build();
           writerAppender.start();
   
           logger.addAppender(writerAppender);
           try {
               ((DefaultCredentialsProvider) 
getWebClient().getCredentialsProvider())
                                               .addCredentials("jetty", 
"jetty".toCharArray());
   
               loadPage("Hi There");
               int unauthorizedCount = 
StringUtils.countMatches(stringWriter.toString(), "HTTP/1.1 401");
               assertEquals(1, unauthorizedCount);
           }
           finally {
               logger.removeAppender(writerAppender);
               Configurator.setLevel(logger.getName(), oldLevel);
           }
   
   This works fine in 2.20.0 and the years before but now with 2.21.0 i fails 
because there is not output at all - stringWriter.toString() returns an empty 
string.
   
   Any idea?
   Will try to help as much as possible, doing debugging or what else needed to 
get this working again with the new versions.
   
   Thanks for the great libaray
       
     Ronald
   
   ## Configuration
   
   **Version:** 2.21.0
   
   **Operating system:** Win
   
   **JDK:** JDK 11
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to