@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; }
@BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @Benchmark public void param1Log4j1Concat() { log4j1Logger.debug("This is a debug [" + ++j + "] message"); }
@BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @Benchmark public void param3Log4j1Concat() { log4j1Logger.debug("Val1=" + ++j + ", val2=" + ++k + ", val3=" + ++m); }