Examples of LoggerStream


Examples of org.apache.logging.log4j.spi.LoggerStream

        assertEquals(LogManager.getRootLogger(), LogManager.getLogger(LogManager.ROOT_LOGGER_NAME));
    }

    @Test
    public void getStream() {
        final LoggerStream stream = logger.getStream(Level.DEBUG);
        stream.println("Debug message 1");
        stream.print("Debug message 2");
        stream.println();
        stream.println(); // verify blank log message
        stream.print("Debug message 3\n");
        stream.print("\r\n"); // verify windows EOL works
        assertEquals(5, results.size());
        assertThat("Incorrect message", results.get(0), startsWith(" DEBUG Debug message 1"));
        assertThat("Incorrect message", results.get(1), startsWith(" DEBUG Debug message 2"));
        assertEquals("Message should be blank-ish", " DEBUG ", results.get(2));
        assertThat("Incorrect message", results.get(3), startsWith(" DEBUG Debug message 3"));
View Full Code Here

Examples of org.apache.logging.log4j.spi.LoggerStream

        assertEquals("Message should be blank-ish", " DEBUG ", results.get(4));
    }

    @Test
    public void getStream_Marker() {
        final LoggerStream stream = logger.getStream(MarkerManager.getMarker("HI"), Level.INFO);
        stream.println("Hello, world!");
        stream.print("How about this?\n");
        stream.println("Is this thing on?");
        assertEquals(3, results.size());
        assertThat("Incorrect message.", results.get(0), startsWith("HI INFO Hello"));
        assertThat("Incorrect message.", results.get(1), startsWith("HI INFO How about"));
        assertThat("Incorrect message.", results.get(2), startsWith("HI INFO Is this"));
    }
View Full Code Here

Examples of org.jboss.logging.util.LoggerStream

      // Install catchers
      if (catchSystemOut)
      {
         logger = org.apache.log4j.Logger.getLogger("STDOUT");
         out = System.out;
         System.setOut(new LoggerStream(logger, Level.INFO, out));
         log.debug("Installed System.out adapter");
      }
     
      if (catchSystemErr)
      {
         logger = org.apache.log4j.Logger.getLogger("STDERR");
         err = System.err;
         OnlyOnceErrorHandler.setOutput(err);
         System.setErr(new LoggerStream(logger, Level.ERROR, err));
         log.debug("Installed System.err adapter");
      }
   }
View Full Code Here

Examples of org.jboss.logging.util.LoggerStream

/*     */   {
/* 406 */     if (this.catchSystemOut)
/*     */     {
/* 408 */       org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("STDOUT");
/* 409 */       this.out = System.out;
/* 410 */       System.setOut(new LoggerStream(logger, Level.INFO, this.out));
/* 411 */       this.log.debug("Installed System.out adapter");
/*     */     }
/*     */
/* 414 */     if (this.catchSystemErr)
/*     */     {
/* 416 */       org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("STDERR");
/* 417 */       this.err = System.err;
/* 418 */       OnlyOnceErrorHandler.setOutput(this.err);
/* 419 */       System.setErr(new LoggerStream(logger, Level.ERROR, this.err));
/* 420 */       this.log.debug("Installed System.err adapter");
/*     */     }
/*     */   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.