Repository: logging-log4j2 Updated Branches: refs/heads/master 20e9d7688 -> 90079e304
LOG4J2-1297 classes and config for performance tests Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/90079e30 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/90079e30 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/90079e30 Branch: refs/heads/master Commit: 90079e304725db0f278bc86fd064b60be5d5efab Parents: 20e9d76 Author: rpopma <[email protected]> Authored: Fri Feb 26 02:13:50 2016 +0900 Committer: rpopma <[email protected]> Committed: Fri Feb 26 02:13:50 2016 +0900 ---------------------------------------------------------------------- .../async/perftest/CountingNoOpAppender.java | 56 ++++++++++++++++++++ .../resources/perf-CountingNoOpAppender.xml | 12 +++++ 2 files changed, 68 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/90079e30/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/CountingNoOpAppender.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/CountingNoOpAppender.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/CountingNoOpAppender.java new file mode 100644 index 0000000..6140fb6 --- /dev/null +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/perftest/CountingNoOpAppender.java @@ -0,0 +1,56 @@ +/* + * 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.core.async.perftest; + +import java.io.Serializable; +import java.util.Objects; + +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; +import org.apache.logging.log4j.core.layout.PatternLayout; + +/** + * No-Operation Appender that counts events. + */ +@Plugin(name = "CountingNoOp", category = "Core", elementType = "appender", printObject = true) +public class CountingNoOpAppender extends AbstractAppender { + + public static long total; + + public CountingNoOpAppender(String name, Layout<?> layout) { + super(name, null, layout); + } + + @Override + public void append(LogEvent event) { + total++; + } + + /** + * Creates a CountingNoOp Appender. + */ + @PluginFactory + public static CountingNoOpAppender createAppender(@PluginAttribute("name") final String name) { + return new CountingNoOpAppender(Objects.requireNonNull(name), null); + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/90079e30/log4j-core/src/test/resources/perf-CountingNoOpAppender.xml ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/resources/perf-CountingNoOpAppender.xml b/log4j-core/src/test/resources/perf-CountingNoOpAppender.xml new file mode 100644 index 0000000..7e38a75 --- /dev/null +++ b/log4j-core/src/test/resources/perf-CountingNoOpAppender.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration status="OFF"> + <Appenders> + <CountingNoOp name="CountingNoOp"> + </CountingNoOp> + </Appenders> + <Loggers> + <Root level="info" includeLocation="false"> + <appender-ref ref="CountingNoOp"/> + </Root> + </Loggers> +</Configuration>
