@TearDown
  public void tearDown() {
    System.clearProperty("log4j.configurationFile");
    System.clearProperty("log4j.configuration");
    System.clearProperty("logback.configurationFile");

    deleteLogFiles();
  }
Ejemplo n.º 2
0
 private static void doTestRun(final ClassicLogger logger, final int repetitions, final int n) {
   startTime[n] = System.currentTimeMillis();
   final long start = System.nanoTime();
   for (int i = 0; i < repetitions; i++) {
     logger.log("Test message str={}, double={}, int={}, obj={}", "abc", i / 2.5, i, "XYX");
   }
   duration[n] = System.nanoTime() - start;
   checksums[n] = logger.appender.checksum;
   logger.appender.checksum = 0;
 }
Ejemplo n.º 3
0
  private static void doTestRunBoth(
      final ClassicLogger classic, final NoGcLogger nogc, final int repetitions, final int n) {
    startTime[n] = System.currentTimeMillis();
    final long start = System.nanoTime();
    for (int i = 0; i < repetitions; i++) {
      classic.log("Test message str={}, double={}, int={}, obj={}", "abc", i / 2.5, i, "XYX");
      nogc.log(
          "Test message str={}, double={}, int={}, obj={}", "abc", box(i / 2.5), box(i), "XYX");

      if (classic.appender.checksum != nogc.appender.checksum) {
        throw new IllegalStateException();
      }
    }
    duration[n] = System.nanoTime() - start;
  }
  @Setup
  public void setUp() throws Exception {
    System.setProperty("log4j.configurationFile", "log4j2-perf.xml");
    System.setProperty("log4j.configuration", "log4j12-perf.xml");
    System.setProperty("logback.configurationFile", "logback-perf.xml");

    deleteLogFiles();

    log4j2Logger = LogManager.getLogger(getClass());
    log4j2RandomLogger = LogManager.getLogger("TestRandom");
    slf4jLogger = LoggerFactory.getLogger(getClass());
    log4j1Logger = org.apache.log4j.Logger.getLogger(getClass());

    julFileHandler = new FileHandler("target/testJulLog.log");
    julLogger = java.util.logging.Logger.getLogger(getClass().getName());
    julLogger.setUseParentHandlers(false);
    julLogger.addHandler(julFileHandler);
    julLogger.setLevel(Level.ALL);
    j = 0;
  }