You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2015/07/12 23:15:29 UTC
[1/2] logging-log4j2 git commit: Add performance tests for
FileAppender
Repository: logging-log4j2
Updated Branches:
refs/heads/master a2fd2ef8a -> 9f1c6adb2
Add performance tests for FileAppender
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/444a7489
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/444a7489
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/444a7489
Branch: refs/heads/master
Commit: 444a7489b93ae4fcd88213413b11c7f7f48c34ac
Parents: f689771
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Jul 12 14:11:29 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Jul 12 14:11:29 2015 -0700
----------------------------------------------------------------------
.../log4j/perf/jmh/FileAppenderBenchmark.java | 142 +++++++++++++++++++
log4j-perf/src/main/resources/log4j12-perf.xml | 31 ++++
log4j-perf/src/main/resources/log4j2-perf.xml | 40 ++++++
log4j-perf/src/main/resources/logback-perf.xml | 30 ++++
4 files changed, 243 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/444a7489/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
new file mode 100644
index 0000000..810a7e9
--- /dev/null
+++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/FileAppenderBenchmark.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.perf.jmh;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Benchmarks Log4j 2, Log4j 1, and Logback using the DEBUG level which is enabled for this test. The configuration
+ * for each uses a FileAppender
+ */
+// HOW TO RUN THIS TEST
+// java -jar target/benchmarks.jar ".*FileAppenderBenchmark.*" -f 1 -i 5 -wi 5 -bm sample -tu ns
+@State(Scope.Thread)
+public class FileAppenderBenchmark {
+ Logger log4jLogger;
+ Logger log4jRandomLogger;
+ org.slf4j.Logger slf4jLogger;
+ org.apache.log4j.Logger log4jClassicLogger;
+ int j;
+
+ @Setup
+ public void setUp() {
+ System.setProperty("log4j.configurationFile", "log4j2-perf.xml");
+ System.setProperty("log4j.configuration", "log4j12-perf.xml");
+ System.setProperty("logback.configurationFile", "logback-perf.xml");
+
+ File logbackFile = new File("target/testlogback.log");
+ logbackFile.delete();
+ File log4jFile = new File ("target/testlog4j.log");
+ log4jFile.delete();
+ File log4j2File = new File ("target/testlog4j2.log");
+ log4j2File.delete();
+
+ log4jLogger = LogManager.getLogger(FileAppenderBenchmark.class);
+ log4jRandomLogger = LogManager.getLogger("TestRandom");
+ slf4jLogger = LoggerFactory.getLogger(FileAppenderBenchmark.class);
+ log4jClassicLogger = org.apache.log4j.Logger.getLogger(FileAppenderBenchmark.class);
+ j = 0;
+ }
+
+ @TearDown
+ public void tearDown() {
+ System.clearProperty("log4j.configurationFile");
+ System.clearProperty("log4j.configuration");
+ System.clearProperty("logback.configurationFile");
+
+ File logbackFile = new File("target/testlogback.log");
+ logbackFile.delete();
+ File log4jFile = new File ("target/testlog4j.log");
+ log4jFile.delete();
+ File log4jRandomFile = new File ("target/testRandomlog4j.log");
+ log4jRandomFile.delete();
+ File log4j2File = new File ("target/testlog4j2.log");
+ log4j2File.delete();
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public boolean baseline() {
+ ++j;
+ return true;
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void log4jRandomDebugStringConcatenation() {
+ log4jRandomLogger.debug("This is a debug [" + ++j + "] message");
+ }
+
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void log4jDebugStringConcatenation() {
+ log4jLogger.debug("This is a debug [" + ++j + "] message");
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void slf4jDebugStringConcatenation() {
+ slf4jLogger.debug("This is a debug [" + ++j + "] message");
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void log4jClassicDebugStringConcatenation() {
+ log4jClassicLogger.debug("This is a debug [" + ++j + "] message");
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void log4jDebugRandomParameterizedString() {
+ log4jRandomLogger.debug("This is a debug [{}] message", ++j);
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void log4jDebugParameterizedString() {
+ log4jLogger.debug("This is a debug [{}] message", ++j);
+ }
+
+ @BenchmarkMode(Mode.Throughput)
+ @OutputTimeUnit(TimeUnit.MILLISECONDS)
+ @Benchmark
+ public void slf4jDebugParameterizedString() {
+ slf4jLogger.debug("This is a debug [{}] message", ++j);
+ }
+}
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/444a7489/log4j-perf/src/main/resources/log4j12-perf.xml
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/resources/log4j12-perf.xml b/log4j-perf/src/main/resources/log4j12-perf.xml
new file mode 100644
index 0000000..e5beacb
--- /dev/null
+++ b/log4j-perf/src/main/resources/log4j12-perf.xml
@@ -0,0 +1,31 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <appender name="TestLogfile" class="org.apache.log4j.FileAppender">
+ <param name="File" value="target/testlog4j.log"/>
+ <param name="immediateFlush" value="false"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %5p [%t] %c{1} %X{transactionId} - %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <level value="debug"/>
+ <appender-ref ref="TestLogfile"/>
+ </root>
+</log4j:configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/444a7489/log4j-perf/src/main/resources/log4j2-perf.xml
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/resources/log4j2-perf.xml b/log4j-perf/src/main/resources/log4j2-perf.xml
new file mode 100644
index 0000000..c23737e
--- /dev/null
+++ b/log4j-perf/src/main/resources/log4j2-perf.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<Configuration name="XMLPerfTest" status="error">
+ <Appenders>
+ <File name="TestLogfile" fileName="target/testlog4j2.log" immediateFlush="false">
+ <PatternLayout>
+ <Pattern>%d %5p [%t] %c{1} %X{transactionId} - %m%n</Pattern>
+ </PatternLayout>
+ </File>
+ <RandomAccessFile name="RandomAccessLogFile" fileName="target/testRandomlog4j2.log" immediateFlush="false">
+ <PatternLayout>
+ <Pattern>%d %5p [%t] %c{1} %X{transactionId} - %m%n</Pattern>
+ </PatternLayout>
+ </RandomAccessFile>
+ </Appenders>
+ <Loggers>
+ <Logger name="TestRandom" level="debug" additivity="false">
+ <AppenderRef ref="RandomAccessLogFile"/>
+ </Logger>
+ <Root level="debug">
+ <AppenderRef ref="TestLogfile"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/444a7489/log4j-perf/src/main/resources/logback-perf.xml
----------------------------------------------------------------------
diff --git a/log4j-perf/src/main/resources/logback-perf.xml b/log4j-perf/src/main/resources/logback-perf.xml
new file mode 100644
index 0000000..ef2cff2
--- /dev/null
+++ b/log4j-perf/src/main/resources/logback-perf.xml
@@ -0,0 +1,30 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<configuration>
+ <appender name="TestLogfile" class="ch.qos.logback.core.FileAppender">
+ <file>target/testlogback.log</file>
+ <encoder>
+ <immediateFlush>false</immediateFlush>
+ <Pattern>%d %5p [%t] %c{0} %X{transactionId} - %m%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="TestLogfile" />
+ </root>
+</configuration>
\ No newline at end of file
[2/2] logging-log4j2 git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/logging-log4j2
Posted by rg...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/logging-log4j2
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9f1c6adb
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9f1c6adb
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9f1c6adb
Branch: refs/heads/master
Commit: 9f1c6adb2c7f7f146a7e77cf1d08b3ad23d3de01
Parents: 444a748 a2fd2ef
Author: Ralph Goers <rg...@nextiva.com>
Authored: Sun Jul 12 14:14:27 2015 -0700
Committer: Ralph Goers <rg...@nextiva.com>
Committed: Sun Jul 12 14:14:27 2015 -0700
----------------------------------------------------------------------
.../java/org/apache/logging/log4j/Marker.java | 208 +++++++--------
log4j-core/pom.xml | 1 +
.../core/appender/OutputStreamManager.java | 2 +-
.../rolling/DefaultRolloverStrategy.java | 40 +--
.../rolling/action/CommonsCompressAction.java | 6 +-
.../core/async/AsyncLoggerConfigHelper.java | 6 +
.../logging/log4j/core/impl/ThrowableProxy.java | 18 +-
.../logging/log4j/core/layout/GelfLayout.java | 2 +-
.../log4j/core/layout/PatternLayout.java | 7 +-
.../core/pattern/DatePatternConverter.java | 48 ++--
.../core/util/datetime/FastDateParser.java | 12 +-
.../core/util/datetime/FastDatePrinter.java | 2 +-
.../log4j/core/util/datetime/Format.java | 8 +-
.../apache/logging/log4j/core/LoggerTest.java | 1 -
...nsoleAppenderDefaultSuppressedThrowable.java | 6 +-
.../ConsoleAppenderNoAnsiStyleLayoutMain.java | 4 +-
.../log4j/core/appender/FileAppenderTest.java | 2 +-
.../core/appender/OutputStreamAppenderTest.java | 2 +-
.../rolling/action/Bzip2CompressActionTest.java | 2 +-
.../plugins/validation/ValidatingPlugin.java | 1 -
.../log4j/core/impl/ThrowableProxyTest.java | 22 +-
.../log4j/core/layout/LogEventFixtures.java | 1 -
.../log4j/core/layout/XmlLayoutTest.java | 1 -
.../log4j/core/selector/TestClassLoader.java | 2 +-
.../log4j/flume/appender/FlumeAvroManager.java | 4 +-
.../log4j/flume/appender/FlumeAppenderTest.java | 2 +-
.../log4j/jul/DefaultLevelConverter.java | 14 +-
...efaultLevelConverterCustomJulLevelsTest.java | 5 +-
.../nosql/appender/mongodb/MongoDbProvider.java | 2 +-
.../perf/jmh/SimpleDateFormatBenchmark.java | 34 +--
.../org/apache/logging/slf4j/Log4jMarker.java | 264 +++++++++----------
.../apache/logging/slf4j/Log4jMarkerTest.java | 76 +++---
.../org/apache/logging/slf4j/MarkerTest.java | 28 +-
pom.xml | 2 +-
34 files changed, 421 insertions(+), 414 deletions(-)
----------------------------------------------------------------------