zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikaelstaldal <...@git.apache.org>
Subject [GitHub] zookeeper pull request #148: ZOOKEEPER-2659 Log4j 2 migration
Date Sun, 15 Jan 2017 19:48:31 GMT
Github user mikaelstaldal commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/148#discussion_r96145970
  
    --- Diff: src/java/test/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java ---
    @@ -470,16 +481,20 @@ public void testBadPeerAddressInQuorum() throws Exception {
         @Test
         public void testInconsistentPeerType() throws Exception {
             ClientBase.setupTestEnv();
    -
    -        // setup the logger to capture all logs
    +        
    +        LoggerContext loggerContext =  (LoggerContext) LogManager.getContext(false);
    +        Configuration logConfig = loggerContext.getConfiguration();
    +        
             Layout layout =
    -                Logger.getRootLogger().getAppender("CONSOLE").getLayout();
    +        		logConfig.getRootLogger().getAppenders().get("STDOUT").getLayout();
    +        String appenderName = "quorumAppender";
             ByteArrayOutputStream os = new ByteArrayOutputStream();
    -        WriterAppender appender = new WriterAppender(layout, os);
    -        appender.setThreshold(Level.INFO);
    -        Logger qlogger = Logger.getLogger("org.apache.zookeeper.server.quorum");
    -        qlogger.addAppender(appender);
    -
    +        WriterAppender appender = WriterAppender.createAppender((StringLayout)layout,
null, new OutputStreamWriter(os), appenderName, false, true);
    --- End diff --
    
    It's probably a good idea to use the builder to create the appender (see above).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message