logging-log4j2 git commit: LOG4J2-1440 - Fix bug in OnStartupTriggeringPolicy that allowed it to roll over on every reconfiguration. Added minSize attribute
Repository: logging-log4j2 Updated Branches: refs/heads/master aed2298e3 -> 07723ec68 LOG4J2-1440 - Fix bug in OnStartupTriggeringPolicy that allowed it to roll over on every reconfiguration. Added minSize attribute Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/07723ec6 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/07723ec6 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/07723ec6 Branch: refs/heads/master Commit: 07723ec6865042952bd09af158ca8c2a952933bc Parents: aed2298 Author: Ralph GoersAuthored: Sun Jun 19 22:22:56 2016 -0700 Committer: Ralph Goers Committed: Sun Jun 19 22:22:56 2016 -0700 -- .../rolling/OnStartupTriggeringPolicy.java | 51 ++-- .../rolling/OnStartupTriggeringPolicyTest.java | 2 +- .../rolling/RollingFileAppenderAccessTest.java | 4 +- src/changes/changes.xml | 4 ++ src/site/xdoc/manual/appenders.xml | 20 +++- 5 files changed, 71 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/07723ec6/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java index d018570..12e2b23 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java @@ -16,16 +16,57 @@ */ package org.apache.logging.log4j.core.appender.rolling; +import java.lang.reflect.Method; + import org.apache.logging.log4j.core.LogEvent; 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.PluginFactory; +import org.apache.logging.log4j.core.util.Loader; +import org.apache.logging.log4j.status.StatusLogger; /** * Triggers a rollover on every restart, but only if the file size is greater than zero. */ @Plugin(name = "OnStartupTriggeringPolicy", category = "Core", printObject = true) public class OnStartupTriggeringPolicy implements TriggeringPolicy { -private RollingFileManager manager; + +private static final long JVM_START_TIME = initStartTime(); + +private final long minSize; + +private OnStartupTriggeringPolicy(long minSize) { +this.minSize = minSize; +} + +/** + * Returns the result of {@code ManagementFactory.getRuntimeMXBean().getStartTime()}, + * or the current system time if JMX is not available. + */ +private static long initStartTime() { +// LOG4J2-379: +// We'd like to call ManagementFactory.getRuntimeMXBean().getStartTime(), +// but Google App Engine throws a java.lang.NoClassDefFoundError +// "java.lang.management.ManagementFactory is a restricted class". +// The reflection is necessary because without it, Google App Engine +// will refuse to initialize this class. +try { +final Class factoryClass = Loader.loadSystemClass("java.lang.management.ManagementFactory"); +final Method getRuntimeMXBean = factoryClass.getMethod("getRuntimeMXBean"); +final Object runtimeMXBean = getRuntimeMXBean.invoke(null); + +final Class runtimeMXBeanClass = Loader.loadSystemClass("java.lang.management.RuntimeMXBean"); +final Method getStartTime = runtimeMXBeanClass.getMethod("getStartTime"); +final Long result = (Long) getStartTime.invoke(runtimeMXBean); + +return result; +} catch (final Throwable t) { +StatusLogger.getLogger().error("Unable to call ManagementFactory.getRuntimeMXBean().getStartTime(), " ++ "using system time for OnStartupTriggeringPolicy", t); +// We have little option but to declare "now" as the beginning of time. +return System.currentTimeMillis(); +} +} /** * Provide the RollingFileManager to the policy. @@ -33,8 +74,7 @@ public class OnStartupTriggeringPolicy implements TriggeringPolicy { */ @Override public void initialize(final RollingFileManager manager) { -this.manager = manager; -if (manager.getFileSize() > 0) { +if (manager.getFileTime() < JVM_START_TIME && manager.getFileSize() >= minSize) { manager.skipFooter(true);
logging-log4j2 git commit: Add support for JCTools in AsyncAppender - thanks Anthony Maire
Repository: logging-log4j2 Updated Branches: refs/heads/feature/LOG4J2-1430 69f264c2e -> fdb6156a9 Add support for JCTools in AsyncAppender - thanks Anthony Maire Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/fdb6156a Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/fdb6156a Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/fdb6156a Branch: refs/heads/feature/LOG4J2-1430 Commit: fdb6156a95e36f469f070a26f4b863153a69e940 Parents: 69f264c Author: Matt SickerAuthored: Sun Jun 19 17:24:41 2016 -0500 Committer: Matt Sicker Committed: Sun Jun 19 17:24:41 2016 -0500 -- log4j-core/pom.xml | 8 +- .../core/async/JCToolsBlockingQueueFactory.java | 93 .../log4j/core/appender/AsyncAppenderTest.java | 5 +- ...lockingQueueFactory-JctoolsBlockingQueue.xml | 40 + log4j-perf/pom.xml | 4 + .../perf/jmh/AsyncAppenderLog4j2Benchmark.java | 1 + .../AsyncAppenderLog4j2LocationBenchmark.java | 1 + .../perf5AsyncApndMpscQNoLoc-noOpAppender.xml | 32 +++ .../perf5AsyncApndMpscQWithLoc-noOpAppender.xml | 32 +++ pom.xml | 6 ++ src/site/xdoc/manual/appenders.xml | 8 ++ 11 files changed, 225 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fdb6156a/log4j-core/pom.xml -- diff --git a/log4j-core/pom.xml b/log4j-core/pom.xml index d2c47bf..cda09f0 100644 --- a/log4j-core/pom.xml +++ b/log4j-core/pom.xml @@ -51,12 +51,18 @@ disruptor true - + com.conversantmedia disruptor true + + + org.jctools + jctools-core + true + com.fasterxml.jackson.core http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/fdb6156a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/JCToolsBlockingQueueFactory.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/JCToolsBlockingQueueFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/JCToolsBlockingQueueFactory.java new file mode 100644 index 000..ccda263 --- /dev/null +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/JCToolsBlockingQueueFactory.java @@ -0,0 +1,93 @@ +package org.apache.logging.log4j.core.async; + +import java.util.Collection; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.LockSupport; + +import org.apache.logging.log4j.core.config.Node; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; +import org.jctools.queues.MpscArrayQueue; + +/** + * Factory for creating instances of BlockingQueues backed by JCTools {@link MpscArrayQueue}. + * + * @since 2.7 + */ +@Plugin(name = "JCToolsBlockingQueue", category = Node.CATEGORY, elementType = BlockingQueueFactory.ELEMENT_TYPE) +public class JCToolsBlockingQueueFactory implements BlockingQueueFactory { + +private JCToolsBlockingQueueFactory() { +} + +@Override +public BlockingQueue create(final int capacity) { +return new MpscBlockingQueue<>(capacity); +} + +@PluginFactory +public static JCToolsBlockingQueueFactory createFactory() { +return new JCToolsBlockingQueueFactory<>(); +} + +/** + * BlockingQueue wrapper for JCTools multiple producer single consumer array queue. + */ +private static final class MpscBlockingQueue extends MpscArrayQueue implements BlockingQueue { + +MpscBlockingQueue(final int capacity) { +super(capacity); +} + +@Override +public int drainTo(final Collection c) { +return drainTo(c, capacity()); +} + +@Override +public int drainTo(final Collection c, final int maxElements) { +return drain(new Consumer() { +@Override +public void accept(E arg0) { +c.add(arg0); +} +}, maxElements); +} + +@Override +public boolean offer(final E e, final long timeout, final TimeUnit unit) throws InterruptedException { +// TODO Auto-generated method stub +return offer(e); +} + +@Override +public E poll(final long timeout, final TimeUnit unit) throws InterruptedException { +// TODO Auto-generated method stub +return poll(); +} + +
[08/40] logging-log4j2 git commit: Add example for JAnsi messages.
Add example for JAnsi messages. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f1b41d03 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f1b41d03 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f1b41d03 Branch: refs/heads/LOG4J-1181 Commit: f1b41d0359e6f930f0c84680eaae6589ea79a5d4 Parents: 334745a Author: ggregoryAuthored: Thu Jun 16 10:33:19 2016 -0700 Committer: ggregory Committed: Thu Jun 16 10:33:19 2016 -0700 -- .../ConsoleAppenderJAnsiMessageMain.java| 75 1 file changed, 75 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f1b41d03/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java new file mode 100644 index 000..53a5bfd --- /dev/null +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java @@ -0,0 +1,75 @@ +/* + * 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.appender; + +import static org.fusesource.jansi.Ansi.*; +import static org.fusesource.jansi.Ansi.Color.*; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configurator; +import org.junit.Test; + +/** + * Shows how to use ANSI escape codes to color messages. Each message is printed to the console in color, but the rest + * of the log entry (time stamp for example) is in the default color for that console. + * + * Running from a Windows command line from the root of the project: + * + * + * + * mvn -Dtest=org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiMessageMain test + * + * + * or: + * + * + * java -classpath log4j-core\target\test-classes;log4j-core\target\classes;log4j-api\target\classes;%HOME%\.m2\repository\org\fusesource\jansi\jansi\1.11\jansi-1.11.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiMessageMain log4j-core/target/test-classes/log4j2-console-style-ansi.xml + * + * + */ +public class ConsoleAppenderJAnsiMessageMain { + +public static void main(final String[] args) { +new ConsoleAppenderJAnsiMessageMain().test(args); +} + +/** + * This is a @Test method to make it easy to run from a command line with {@code mvn -Dtest=FQCN test} + */ +@Test +public void test() { +test(null); +} + +public void test(final String[] args) { +// System.out.println(System.getProperty("java.class.path")); +final String config = args == null || args.length == 0 ? "target/test-classes/log4j2-console-style-ansi.xml" +: args[0]; +final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config); +final Logger logger = LogManager.getLogger(ConsoleAppenderJAnsiMessageMain.class); +try { +logger.info(ansi().fg(RED).a("Hello").fg(CYAN).a(" World").reset()); +// JAnsi format: +// logger.info("@|red Hello|@ @|cyan World|@"); +} finally { +Configurator.shutdown(ctx); +} +} + +}
[11/40] logging-log4j2 git commit: Add final modifier to method parameters.
Add final modifier to method parameters. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/df7dce82 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/df7dce82 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/df7dce82 Branch: refs/heads/LOG4J-1181 Commit: df7dce82af77f1e0b4fb623bc624d835ee2c8ba6 Parents: ea23f07 Author: ggregoryAuthored: Thu Jun 16 15:51:55 2016 -0700 Committer: ggregory Committed: Thu Jun 16 15:51:55 2016 -0700 -- .../apache/logging/log4j/core/appender/OutputStreamManager.java| 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/df7dce82/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java index 825e2c5..1adacb5 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/OutputStreamManager.java @@ -85,7 +85,7 @@ public class OutputStreamManager extends AbstractManager implements ByteBufferDe * Indicate whether the footer should be skipped or not. * @param skipFooter true if the footer should be skipped. */ -public void skipFooter(boolean skipFooter) { +public void skipFooter(final boolean skipFooter) { this.skipFooter = skipFooter; }
[33/40] logging-log4j2 git commit: LOG4J2-1414 Fixed minor issues with the 2.6.1 web site.
LOG4J2-1414 Fixed minor issues with the 2.6.1 web site. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1a19f75d Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1a19f75d Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1a19f75d Branch: refs/heads/LOG4J-1181 Commit: 1a19f75dc2dafdefe5b848d63f759a5e90145ac4 Parents: 52e769f Author: rpopmaAuthored: Sun Jun 19 13:29:18 2016 +0900 Committer: rpopma Committed: Sun Jun 19 13:29:18 2016 +0900 -- src/changes/changes.xml | 3 +++ src/site/xdoc/manual/messages.xml | 24 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1a19f75d/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 7f5eeaa..a91eab4 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -24,6 +24,9 @@ + +Fixed minor issues with the 2.6.1 web site. + Ensure that the thread-local StringBuilders used by Layouts to format log events to text will not retain excessive memory after a large message was logged. http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1a19f75d/src/site/xdoc/manual/messages.xml -- diff --git a/src/site/xdoc/manual/messages.xml b/src/site/xdoc/manual/messages.xml index bdf3b61..84a6622 100644 --- a/src/site/xdoc/manual/messages.xml +++ b/src/site/xdoc/manual/messages.xml @@ -223,7 +223,8 @@ public class MyApp { ObjectMessage - Formats an Object by calling its toString method. + Formats an Object by calling its toString method. Since Log4j 2.6, Layouts trying to be low-garbage or + garbage-free will call the formatTo(StringBuilder) method instead. ParameterizedMessage @@ -232,10 +233,29 @@ public class MyApp { handles messages that contain "{}" in the format to represent replaceable tokens and the replacement parameters. + ReusableObjectMessage + + + In garbage-free mode, this message is used to pass logged Objects to the Layout and Appenders. + Functionally equivalent to ObjectMessage. + + ReusableObjectMessage + + + In garbage-free mode, this message is used to handle messages that contain "{}" in the format to + represent replaceable tokens and the replacement parameters. + Functionally equivalent to ParameterizedMessage. + + ReusableSimpleMessage + + + In garbage-free mode, this message is used to pass logged Strings and CharSequences to the Layout and Appenders. + Functionally equivalent to SimpleMessage. + SimpleMessage - SimpleMessage contains a String that requires no formatting. + SimpleMessage contains a String or CharSequence that requires no formatting. StringFormattedMessage
[01/40] logging-log4j2 git commit: Fix system property description in manual
Repository: logging-log4j2 Updated Branches: refs/heads/LOG4J-1181 b61f043d3 -> 75277a485 Fix system property description in manual Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2efb0765 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2efb0765 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2efb0765 Branch: refs/heads/LOG4J-1181 Commit: 2efb07652a720064661e5bc911d3697f76da9e54 Parents: 24bfc3e Author: Matt SickerAuthored: Tue Jun 14 10:36:25 2016 -0500 Committer: Matt Sicker Committed: Tue Jun 14 10:36:35 2016 -0500 -- src/site/xdoc/manual/configuration.xml.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2efb0765/src/site/xdoc/manual/configuration.xml.vm -- diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm index 2ac69eb..6fb4900 100644 --- a/src/site/xdoc/manual/configuration.xml.vm +++ b/src/site/xdoc/manual/configuration.xml.vm @@ -1893,7 +1893,7 @@ public class AwesomeTest { AsyncLoggerConfig.WaitStrategy - Sleep + Timeout See Mixed Async/Synchronous Logger System Properties for details.
[16/40] logging-log4j2 git commit: Add missing '@Override' annotations.
Add missing '@Override' annotations. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8fa2410b Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8fa2410b Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8fa2410b Branch: refs/heads/LOG4J-1181 Commit: 8fa2410bd01826ef673908124f28cca93aa03f20 Parents: 2060b72 Author: ggregoryAuthored: Fri Jun 17 10:31:06 2016 -0700 Committer: ggregory Committed: Fri Jun 17 10:31:06 2016 -0700 -- .../logging/log4j/core/config/builder/impl/BuiltConfiguration.java | 1 + .../log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java | 1 + .../logging/log4j/core/impl/ReusableLogEventFactoryTest.java | 2 ++ 3 files changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8fa2410b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java index 4dcd293..029caf2 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/impl/BuiltConfiguration.java @@ -162,6 +162,7 @@ public class BuiltConfiguration extends AbstractConfiguration { } } +@Override public PluginManager getPluginManager() { return pluginManager; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8fa2410b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java index b4da847..0d6ec1b 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java @@ -84,6 +84,7 @@ public class AsyncAppenderQueueFullPolicyTest { assertEquals("EventRouter invocations", 0, policy.queueFull.get()); final Thread release = new Thread("AsyncAppenderReleaser") { +@Override public void run() { while (policy.queueFull.get() == 0) { try { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8fa2410b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java index 78c83ac..f163529 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ReusableLogEventFactoryTest.java @@ -67,11 +67,13 @@ public class ReusableLogEventFactoryTest { final LogEvent[] event1 = new LogEvent[1]; final LogEvent[] event2 = new LogEvent[1]; final Thread t1 = new Thread("THREAD 1") { +@Override public void run() { event1[0] = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null); } }; final Thread t2 = new Thread("Thread 2") { +@Override public void run() { event2[0] = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null); }
[30/40] logging-log4j2 git commit: LOG4J2-1434 Ensure max size cannot be configured to too small size.
LOG4J2-1434 Ensure max size cannot be configured to too small size. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6eff4fc4 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6eff4fc4 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6eff4fc4 Branch: refs/heads/LOG4J-1181 Commit: 6eff4fc461b8dcdfcc5c30d7583179204089dce2 Parents: 189c0d0 Author: rpopmaAuthored: Sun Jun 19 09:06:07 2016 +0900 Committer: rpopma Committed: Sun Jun 19 09:06:07 2016 +0900 -- .../apache/logging/log4j/core/layout/AbstractStringLayout.java| 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/6eff4fc4/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java index c2edd6f..2d11ade 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java @@ -58,7 +58,8 @@ public abstract class AbstractStringLayout extends AbstractLayout implem */ protected static final int DEFAULT_STRING_BUILDER_SIZE = 1024; -protected static final int MAX_STRING_BUILDER_SIZE = size("log4j.layoutStringBuilder.maxSize", 2 * 1024); +protected static final int MAX_STRING_BUILDER_SIZE = Math.max(DEFAULT_STRING_BUILDER_SIZE, +size("log4j.layoutStringBuilder.maxSize", 2 * 1024)); private static final ThreadLocal threadLocal = new ThreadLocal<>();
[37/40] logging-log4j2 git commit: Merge branch 'master' into LOG4J-1181
Merge branch 'master' into LOG4J-1181 Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/88044f34 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/88044f34 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/88044f34 Branch: refs/heads/LOG4J-1181 Commit: 88044f34c47680697e1a960e581fde5b052eb1a6 Parents: b61f043 aed2298 Author: Mikael StåldalAuthored: Sun Jun 19 21:01:30 2016 +0200 Committer: Mikael Ståldal Committed: Sun Jun 19 21:01:30 2016 +0200 -- .../logging/log4j/message/ObjectMessage.java| 14 +++ .../log4j/message/ParameterizedMessage.java | 15 ++- .../log4j/message/ReusableObjectMessage.java| 14 +++ .../org/apache/logging/log4j/util/Unbox.java| 4 +- .../core/appender/MemoryMappedFileManager.java | 2 + .../core/appender/OutputStreamManager.java | 2 +- .../rolling/OnStartupTriggeringPolicy.java | 4 - .../rolling/action/FileRenameAction.java| 4 - .../log4j/core/config/Configuration.java| 6 +- .../log4j/core/config/ConfigurationFactory.java | 19 ++-- .../logging/log4j/core/config/Configurator.java | 3 +- .../builder/api/ConfigurationBuilder.java | 1 - .../config/builder/impl/BuiltConfiguration.java | 1 + .../config/composite/DefaultMergeStrategy.java | 3 +- .../log4j/core/filter/CompositeFilter.java | 7 +- .../log4j/core/jackson/LogEventJsonMixIn.java | 2 - .../core/layout/AbstractJacksonLayout.java | 1 - .../log4j/core/layout/AbstractStringLayout.java | 12 +++ .../log4j/core/layout/CsvParameterLayout.java | 1 - .../logging/log4j/core/layout/GelfLayout.java | 37 --- .../log4j/core/pattern/NameAbbreviator.java | 102 +-- .../core/GcFreeMixedSyncAyncLoggingTest.java| 1 - .../core/GcFreeSynchronousLoggingTest.java | 1 - .../AsyncAppenderQueueFullPolicyTest.java | 6 +- .../ConsoleAppenderAnsiStyleLayoutMain.java | 40 ++-- .../ConsoleAppenderJAnsiMessageMain.java| 75 ++ .../log4j/core/appender/FileAppenderTest.java | 37 --- .../rolling/OnStartupTriggeringPolicyTest.java | 16 +-- .../RandomRollingAppenderOnStartupTest.java | 6 +- .../rolling/RollingAppenderOnStartupTest.java | 13 +-- .../rolling/RollingAppenderSizeTest.java| 4 +- .../core/config/CompositeConfigurationTest.java | 6 -- .../core/filter/AbstractFilterableTest.java | 12 ++- .../log4j/core/impl/MutableLogEventTest.java| 1 - .../core/impl/ReusableLogEventFactoryTest.java | 2 + .../core/layout/AbstractStringLayoutTest.java | 72 + .../layout/CsvParameterLayoutAllAsyncTest.java | 1 - .../log4j/test/appender/BlockingAppender.java | 3 - ...ractStringLayoutStringEncodingBenchmark.java | 4 +- .../AsyncAppenderLog4j2LocationBenchmark.java | 2 - .../perf/jmh/AsyncAppenderLogbackBenchmark.java | 1 - .../AsyncAppenderLogbackLocationBenchmark.java | 2 - .../perf/jmh/AsyncLoggersLocationBenchmark.java | 2 - .../jmh/MemoryHandlerJULLocationBenchmark.java | 2 - .../perf/jmh/ThreadsafeDateFormatBenchmark.java | 6 +- pom.xml | 4 +- src/changes/changes.xml | 18 +++- src/site/xdoc/manual/configuration.xml.vm | 11 +- src/site/xdoc/manual/messages.xml | 24 - 49 files changed, 425 insertions(+), 201 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/88044f34/pom.xml --
[22/40] logging-log4j2 git commit: LOG4J2-1422 fix spuriously failing test
LOG4J2-1422 fix spuriously failing test Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a9b662e5 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a9b662e5 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a9b662e5 Branch: refs/heads/LOG4J-1181 Commit: a9b662e51351d1fd4af4f607c140c638f8d877f4 Parents: 9b16256 Author: rpopmaAuthored: Sat Jun 18 09:05:20 2016 +0900 Committer: rpopma Committed: Sat Jun 18 09:05:20 2016 +0900 -- .../log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a9b662e5/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java index 0d6ec1b..1e7ca92 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java @@ -79,6 +79,9 @@ public class AsyncAppenderQueueFullPolicyTest { logger.error("event 1 - gets taken off the queue"); logger.warn("event 2"); logger.info("event 3"); +while (asyncAppender.getQueueRemainingCapacity() == 0) { +Thread.yield(); // wait until background thread takes one element off the queue +} logger.info("event 4 - now the queue is full"); assertEquals("queue remaining capacity", 0, asyncAppender.getQueueRemainingCapacity()); assertEquals("EventRouter invocations", 0, policy.queueFull.get());
[28/40] logging-log4j2 git commit: LOG4J2-1434 Ensure that the thread-local StringBuilders used to format log events to text will not retain excessive memory after a large message was logged.
LOG4J2-1434 Ensure that the thread-local StringBuilders used to format log events to text will not retain excessive memory after a large message was logged. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/945cea3a Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/945cea3a Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/945cea3a Branch: refs/heads/LOG4J-1181 Commit: 945cea3a6ea405e2cddbd622e92f82590c6231d9 Parents: db47cde Author: rpopmaAuthored: Sat Jun 18 16:05:34 2016 +0900 Committer: rpopma Committed: Sat Jun 18 16:05:34 2016 +0900 -- .../logging/log4j/core/layout/AbstractStringLayout.java | 11 +++ src/changes/changes.xml | 4 src/site/xdoc/manual/configuration.xml.vm| 7 ++- 3 files changed, 21 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/945cea3a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java index 4d4e761..c2edd6f 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.LoggerConfig; import org.apache.logging.log4j.core.util.Constants; import org.apache.logging.log4j.core.util.StringEncoder; +import org.apache.logging.log4j.util.PropertiesUtil; import org.apache.logging.log4j.util.Strings; import java.io.UnsupportedEncodingException; @@ -57,10 +58,16 @@ public abstract class AbstractStringLayout extends AbstractLayout implem */ protected static final int DEFAULT_STRING_BUILDER_SIZE = 1024; +protected static final int MAX_STRING_BUILDER_SIZE = size("log4j.layoutStringBuilder.maxSize", 2 * 1024); + private static final ThreadLocal threadLocal = new ThreadLocal<>(); private Encoder textEncoder; +private static int size(final String property, final int defaultValue) { +return PropertiesUtil.getProperties().getIntegerProperty(property, defaultValue); +} + /** * Returns a {@code StringBuilder} that this Layout implementation can use to write the formatted log event to. * @@ -72,6 +79,10 @@ public abstract class AbstractStringLayout extends AbstractLayout implem result = new StringBuilder(DEFAULT_STRING_BUILDER_SIZE); threadLocal.set(result); } +if (result.length() > MAX_STRING_BUILDER_SIZE) { +result.setLength(MAX_STRING_BUILDER_SIZE); +result.trimToSize(); +} result.setLength(0); return result; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/945cea3a/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 0de777c..d5cf56a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -24,6 +24,10 @@ + +Ensure that the thread-local StringBuilders used to format log events to text will not retain excessive +memory after a large message was logged. + Add "direct" option to ConsoleAppender for increased performance. http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/945cea3a/src/site/xdoc/manual/configuration.xml.vm -- diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm index 1276a0e..65843e3 100644 --- a/src/site/xdoc/manual/configuration.xml.vm +++ b/src/site/xdoc/manual/configuration.xml.vm @@ -1985,7 +1985,12 @@ public class AwesomeTest { In GC-free mode, this property determines the maximum size of the reusable StringBuilders where the message text is formatted and potentially passed to background threads. - + +log4j.layoutStringBuilder.maxSize +2048 +This property determines the maximum size of the thread-local reusable StringBuilders + used to format the log event to text by Layouts that extend AbstractStringLayout. + log4j.unbox.ringbuffer.size 32
[03/40] logging-log4j2 git commit: [LOG4J2-1432] Update Jackson from 2.7.4 to 2.7.5. I had to @Ignore RollingAppenderSizeTest in order to get all Core tests to pass. The RollingAppenderSizeTest failur
[LOG4J2-1432] Update Jackson from 2.7.4 to 2.7.5. I had to @Ignore RollingAppenderSizeTest in order to get all Core tests to pass. The RollingAppenderSizeTest failure happens without this update. See the dev ML. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b3f45fb9 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b3f45fb9 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b3f45fb9 Branch: refs/heads/LOG4J-1181 Commit: b3f45fb9a3dd42c4ceb1e46a41b85fefbbbff31e Parents: e262eda Author: ggregoryAuthored: Wed Jun 15 19:11:25 2016 -0700 Committer: ggregory Committed: Wed Jun 15 19:11:25 2016 -0700 -- pom.xml | 2 +- src/changes/changes.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b3f45fb9/pom.xml -- diff --git a/pom.xml b/pom.xml index 8cd67a0..85f9309 100644 --- a/pom.xml +++ b/pom.xml @@ -192,7 +192,7 @@ 1.7.21 1.1.7 1.9.13 -2.7.4 +2.7.5 3.2.13.RELEASE 1.6.0 3.3.4 http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b3f45fb9/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b217bf3..c329c52 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -45,6 +45,9 @@ Unbox utility's ringbuffer of StringBuilders is now configurable. + +Update Jackson from 2.7.4 to 2.7.5. +
[35/40] logging-log4j2 git commit: LOG4J2-1434 added more tests test to verify that StringBuilder capacity is reset to at most MAX on each call to AbstractStringLayout.getStringBuilder()
LOG4J2-1434 added more tests test to verify that StringBuilder capacity is reset to at most MAX on each call to AbstractStringLayout.getStringBuilder() Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/13b453ce Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/13b453ce Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/13b453ce Branch: refs/heads/LOG4J-1181 Commit: 13b453ce57518f5c1886a5761a7e9ca7b66a2544 Parents: d953cbf Author: rpopmaAuthored: Sun Jun 19 14:03:33 2016 +0900 Committer: rpopma Committed: Sun Jun 19 14:03:33 2016 +0900 -- .../core/layout/AbstractStringLayoutTest.java | 23 +++- 1 file changed, 17 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/13b453ce/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java index f213a31..fcd4ae1 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java @@ -46,16 +46,27 @@ public class AbstractStringLayoutTest { @Test public void testGetStringBuilderCapacityRestrictedToMax() throws Exception { -final int LARGE = 4096; -final String largeMessage = new String(new char[LARGE]); final StringBuilder sb = ConcreteStringLayout.getStringBuilder(); assertEquals("initial capacity", ConcreteStringLayout.DEFAULT_STRING_BUILDER_SIZE, sb.capacity()); -sb.append(largeMessage); -assertEquals("capacity=msg length", LARGE, sb.capacity()); -assertEquals("capacity=msg length", LARGE, sb.length()); + +final int MEDIUM = ConcreteStringLayout.DEFAULT_STRING_BUILDER_SIZE + 100; +final String mediumMessage = new String(new char[MEDIUM]); +sb.append(mediumMessage); +final int GROWN = sb.capacity(); +assertTrue("capacity has grown", GROWN >= MEDIUM); +assertEquals("length=msg length", MEDIUM, sb.length()); + +final int LARGE = 4096; +final String largeMessage = new String(new char[LARGE]); +final StringBuilder sb2 = ConcreteStringLayout.getStringBuilder(); +assertEquals("resized capacity", GROWN, sb2.capacity()); +assertEquals("empty, ready for use", 0, sb2.length()); +sb2.append(largeMessage); +assertTrue("capacity grown to fit msg length", sb2.capacity() >= LARGE); +assertEquals("length=msg length", LARGE, sb2.length()); final StringBuilder next = ConcreteStringLayout.getStringBuilder(); assertEquals("max capacity", ConcreteStringLayout.MAX_STRING_BUILDER_SIZE, next.capacity()); -assertEquals("empty, ready for use", 0, sb.length()); +assertEquals("empty, ready for use", 0, next.length()); } } \ No newline at end of file
[39/40] logging-log4j2 git commit: Use more macros
Use more macros Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f99223e4 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f99223e4 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f99223e4 Branch: refs/heads/LOG4J-1181 Commit: f99223e4a616bbd23bfe1a63f608d7af6dd0c044 Parents: 2b71356 Author: Mikael StåldalAuthored: Sun Jun 19 21:52:27 2016 +0200 Committer: Mikael Ståldal Committed: Sun Jun 19 21:52:27 2016 +0200 -- .../org/apache/logging/log4j/scala/Logger.scala | 16 +++-- .../logging/log4j/scala/LoggerMacro.scala | 36 +++- .../apache/logging/log4j/scala/LoggerTest.scala | 29 +++- .../org/apache/logging/log4j/scala/Logger.scala | 16 +++-- .../logging/log4j/scala/LoggerMacro.scala | 34 ++ .../apache/logging/log4j/scala/LoggerTest.scala | 29 +++- 6 files changed, 137 insertions(+), 23 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f99223e4/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala -- diff --git a/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala b/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala index 7284f84..182e29a 100644 --- a/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala +++ b/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala @@ -298,7 +298,8 @@ class Logger(val delegate: ExtendedLogger) { def traceEntry(params: Any*): EntryMessage = macro LoggerMacro.traceEntryParams - def traceEntry(message: Message): EntryMessage = delegate.traceEntry(message) + def traceEntry(message: Message): EntryMessage = + macro LoggerMacro.traceEntryMessage def traceExit(): Unit = delegate.traceExit() @@ -308,7 +309,8 @@ class Logger(val delegate: ExtendedLogger) { def traceExit[R](entryMessage: EntryMessage, result: R): R = delegate.traceExit(entryMessage, result) - def traceExit[R](message: Message, result: R): R = delegate.traceExit(message, result) + def traceExit[R](message: Message, result: R): R = + macro LoggerMacro.traceExitMessageResult[R] def throwing[T <: Throwable](t: T): T = delegate.throwing(t) @@ -362,8 +364,16 @@ class Logger(val delegate: ExtendedLogger) { delegate.logMessage(FQCN, level, marker, messageFactory.newMessage(message), cause) } - private[scala] def traceEntryWithParams(params: Any*): EntryMessage = { + private[scala] def traceEntryParams(params: Any*): EntryMessage = { delegate.traceEntry(null, params) // TODO should not do ifEnabled check } + private[scala] def traceEntryMessage(message: Message): EntryMessage = { +delegate.traceEntry(message) // TODO should not do ifEnabled check + } + + private[scala] def traceExitMessageResult[R](message: Message, result: R): Unit = { +delegate.traceExit(message, result) // TODO should not do ifEnabled check + } + } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f99223e4/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/LoggerMacro.scala -- diff --git a/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/LoggerMacro.scala b/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/LoggerMacro.scala index a1ebee7..5f119bb 100644 --- a/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/LoggerMacro.scala +++ b/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/LoggerMacro.scala @@ -25,7 +25,7 @@ import scala.reflect.macros.Context private object LoggerMacro { - type LoggerContext = Context { type PrefixType = Logger } + type LoggerContext = Context {type PrefixType = Logger} def fatalMarkerMsg(c: LoggerContext)(marker: c.Expr[Marker], message: c.Expr[Message]) = @@ -36,7 +36,7 @@ private object LoggerMacro { def fatalMarkerObject(c: LoggerContext)(marker: c.Expr[Marker], message: c.Expr[AnyRef]) = logMarkerObject(c)(c.universe.reify(Level.FATAL), marker, message) - + def fatalMarkerMsgThrowable(c: LoggerContext)(marker: c.Expr[Marker], message: c.Expr[Message], cause: c.Expr[Throwable]) = logMarkerMsgThrowable(c)(c.universe.reify(Level.FATAL), marker, message, cause) @@ -45,7 +45,7 @@ private object LoggerMacro { def fatalMarkerObjectThrowable(c: LoggerContext)(marker: c.Expr[Marker], message: c.Expr[AnyRef], cause: c.Expr[Throwable]) = logMarkerObjectThrowable(c)(c.universe.reify(Level.FATAL), marker, message, cause) - +
[09/40] logging-log4j2 git commit: Refactor magic number into a constant. Should this be configurable?
Refactor magic number into a constant. Should this be configurable? Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/906f5109 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/906f5109 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/906f5109 Branch: refs/heads/LOG4J-1181 Commit: 906f5109f7b27ed1b5403297c29e3a5296aa063d Parents: f1b41d0 Author: ggregoryAuthored: Thu Jun 16 15:50:40 2016 -0700 Committer: ggregory Committed: Thu Jun 16 15:50:40 2016 -0700 -- .../org/apache/logging/log4j/message/ParameterizedMessage.java | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/906f5109/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java index c48ab14..d9b9ea5 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java @@ -29,6 +29,10 @@ import org.apache.logging.log4j.util.StringBuilderFormattable; * */ public class ParameterizedMessage implements Message, StringBuilderFormattable { + +// Should this be configurable? +private static final int DEFAULT_STRING_BUILDER_SIZE = 255; + /** * Prefix for recursion. */ @@ -199,7 +203,7 @@ public class ParameterizedMessage implements Message, StringBuilderFormattable { private static StringBuilder getThreadLocalStringBuilder() { StringBuilder buffer = threadLocalStringBuilder.get(); if (buffer == null) { -buffer = new StringBuilder(255); +buffer = new StringBuilder(DEFAULT_STRING_BUILDER_SIZE); threadLocalStringBuilder.set(buffer); } buffer.setLength(0);
[13/40] logging-log4j2 git commit: Don't need these parens.
Don't need these parens. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/be2393e4 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/be2393e4 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/be2393e4 Branch: refs/heads/LOG4J-1181 Commit: be2393e407beade52a51530a5206d8d4a2d84018 Parents: 830f325 Author: ggregoryAuthored: Fri Jun 17 10:25:19 2016 -0700 Committer: ggregory Committed: Fri Jun 17 10:25:19 2016 -0700 -- .../org/apache/logging/log4j/message/ParameterizedMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/be2393e4/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java index 633c295..0994d00 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java @@ -145,7 +145,7 @@ public class ParameterizedMessage implements Message, StringBuilderFormattable { this.indices = new int[messagePattern == null ? 0 : messagePattern.length() >> 1]; // divide by 2 final int placeholders = ParameterFormatter.countArgumentPlaceholders2(messagePattern, indices); initThrowable(argArray, placeholders); -this.usedCount = Math.min(placeholders, (argArray == null) ? 0 : argArray.length); +this.usedCount = Math.min(placeholders, argArray == null ? 0 : argArray.length); } private void initThrowable(final Object[] params, final int usedParams) {
[36/40] logging-log4j2 git commit: LOG4J2-1434 Ensure that the thread-local StringBuilder in GelfLayout will not retain excessive memory after a large message was logged.
LOG4J2-1434 Ensure that the thread-local StringBuilder in GelfLayout will not retain excessive memory after a large message was logged. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/aed2298e Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/aed2298e Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/aed2298e Branch: refs/heads/LOG4J-1181 Commit: aed2298e3272164804266a7ed7a47b8b6dc3ee00 Parents: 13b453c Author: Mikael StåldalAuthored: Sun Jun 19 11:08:06 2016 +0200 Committer: Mikael Ståldal Committed: Sun Jun 19 11:08:06 2016 +0200 -- .../logging/log4j/core/layout/GelfLayout.java | 37 +--- 1 file changed, 24 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aed2298e/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java index 13a14f9..098d18c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java @@ -16,6 +16,17 @@ */ package org.apache.logging.log4j.core.layout; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Map; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.GZIPOutputStream; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.Layout; import org.apache.logging.log4j.core.LogEvent; @@ -32,17 +43,6 @@ import org.apache.logging.log4j.status.StatusLogger; import org.apache.logging.log4j.util.StringBuilderFormattable; import org.apache.logging.log4j.util.Strings; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.Map; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.GZIPOutputStream; - /** * Lays out events in the Graylog Extended Log Format (GELF) 1.1. * @@ -231,8 +231,12 @@ public final class GelfLayout extends AbstractStringLayout { JsonUtils.quoteAsString(((CharSequence)message), builder); } else if (gcFree && message instanceof StringBuilderFormattable) { final StringBuilder messageBuffer = getMessageStringBuilder(); -((StringBuilderFormattable)message).formatTo(messageBuffer); -JsonUtils.quoteAsString(messageBuffer, builder); +try { +((StringBuilderFormattable) message).formatTo(messageBuffer); +JsonUtils.quoteAsString(messageBuffer, builder); +} finally { +returnMessageStringBuilder(messageBuffer); +} } else { JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), builder); } @@ -253,6 +257,13 @@ public final class GelfLayout extends AbstractStringLayout { return result; } +private void returnMessageStringBuilder(StringBuilder stringBuilder) { +if (stringBuilder.length() > MAX_STRING_BUILDER_SIZE) { +stringBuilder.setLength(MAX_STRING_BUILDER_SIZE); +stringBuilder.trimToSize(); +} +} + private CharSequence toNullSafeString(final CharSequence s) { return s == null ? Strings.EMPTY : s; }
[20/40] logging-log4j2 git commit: Fix comment.
Fix comment. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9b162560 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9b162560 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9b162560 Branch: refs/heads/LOG4J-1181 Commit: 9b162560fb9dcdfaebc84b15515c538c0b738460 Parents: 7ffc98e Author: ggregoryAuthored: Fri Jun 17 15:53:26 2016 -0700 Committer: ggregory Committed: Fri Jun 17 15:53:26 2016 -0700 -- .../log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9b162560/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java index 53a5bfd..cbee636 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderJAnsiMessageMain.java @@ -36,10 +36,10 @@ import org.junit.Test; * mvn -Dtest=org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiMessageMain test * * - * or: + * or, on Windows: * * - * java -classpath log4j-core\target\test-classes;log4j-core\target\classes;log4j-api\target\classes;%HOME%\.m2\repository\org\fusesource\jansi\jansi\1.11\jansi-1.11.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiMessageMain log4j-core/target/test-classes/log4j2-console-style-ansi.xml + * java -classpath log4j-core\target\test-classes;log4j-core\target\classes;log4j-api\target\classes;%HOMEDRIVE%\%HOMEPATH%\.m2\repository\org\fusesource\jansi\jansi\1.11\jansi-1.11.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderJAnsiMessageMain log4j-core/target/test-classes/log4j2-console-style-ansi.xml * * */
[07/40] logging-log4j2 git commit: Better issue description.
Better issue description. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/334745a5 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/334745a5 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/334745a5 Branch: refs/heads/LOG4J-1181 Commit: 334745a5f7f005050d8c63f5c4345e3f15a66be3 Parents: 0dd55a0 Author: ggregoryAuthored: Thu Jun 16 10:32:03 2016 -0700 Committer: ggregory Committed: Thu Jun 16 10:32:03 2016 -0700 -- src/changes/changes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/334745a5/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index b76cce7..0de777c 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -25,7 +25,7 @@ -"direct" option to ConsoleAppender for increased performance. +Add "direct" option to ConsoleAppender for increased performance. Provide MessageFactory2 to custom Logger implementations.
[19/40] logging-log4j2 git commit: Oops, fix imports.
Oops, fix imports. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/7ffc98e9 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/7ffc98e9 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/7ffc98e9 Branch: refs/heads/LOG4J-1181 Commit: 7ffc98e978576fb8eaeb6d4c604a9205f598056b Parents: e962b16 Author: ggregoryAuthored: Fri Jun 17 14:24:28 2016 -0700 Committer: ggregory Committed: Fri Jun 17 14:24:28 2016 -0700 -- .../org/apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/7ffc98e9/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java -- diff --git a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java index f7405c2..538dc8d 100644 --- a/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java +++ b/log4j-jmx-gui/src/main/java/org/apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java @@ -22,6 +22,8 @@ import java.util.Map; import javax.swing.JPanel; import javax.swing.SwingWorker; +import com.sun.tools.jconsole.JConsolePlugin; + /** * Adapts the {@code ClientGui} to the {@code JConsolePlugin} API. */
[12/40] logging-log4j2 git commit: Don't hide ivar name.
Don't hide ivar name. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/830f325f Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/830f325f Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/830f325f Branch: refs/heads/LOG4J-1181 Commit: 830f325f294ce7f482a3c3ee82dc5ac8d49adfec Parents: df7dce8 Author: ggregoryAuthored: Fri Jun 17 10:24:54 2016 -0700 Committer: ggregory Committed: Fri Jun 17 10:24:54 2016 -0700 -- .../org/apache/logging/log4j/message/ParameterizedMessage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/830f325f/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java index 4638fb5..633c295 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java @@ -143,9 +143,9 @@ public class ParameterizedMessage implements Message, StringBuilderFormattable { private void init(final String messagePattern) { this.messagePattern = messagePattern; this.indices = new int[messagePattern == null ? 0 : messagePattern.length() >> 1]; // divide by 2 -final int usedCount = ParameterFormatter.countArgumentPlaceholders2(messagePattern, indices); -initThrowable(argArray, usedCount); -this.usedCount = Math.min(usedCount, (argArray == null) ? 0 : argArray.length); +final int placeholders = ParameterFormatter.countArgumentPlaceholders2(messagePattern, indices); +initThrowable(argArray, placeholders); +this.usedCount = Math.min(placeholders, (argArray == null) ? 0 : argArray.length); } private void initThrowable(final Object[] params, final int usedParams) {
[17/40] logging-log4j2 git commit: Remove unused imports.
Remove unused imports. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/706400b7 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/706400b7 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/706400b7 Branch: refs/heads/LOG4J-1181 Commit: 706400b76108ca5699cd3f5e3cc0f4caaf467805 Parents: 8fa2410 Author: ggregoryAuthored: Fri Jun 17 10:33:37 2016 -0700 Committer: ggregory Committed: Fri Jun 17 10:33:37 2016 -0700 -- .../core/appender/rolling/OnStartupTriggeringPolicy.java | 4 .../log4j/core/appender/rolling/action/FileRenameAction.java | 4 .../log4j/core/config/builder/api/ConfigurationBuilder.java | 1 - .../apache/logging/log4j/core/jackson/LogEventJsonMixIn.java | 2 -- .../logging/log4j/core/layout/AbstractJacksonLayout.java | 1 - .../apache/logging/log4j/core/layout/CsvParameterLayout.java | 1 - .../logging/log4j/core/GcFreeMixedSyncAyncLoggingTest.java| 1 - .../logging/log4j/core/GcFreeSynchronousLoggingTest.java | 1 - .../core/appender/rolling/RollingAppenderOnStartupTest.java | 7 --- .../logging/log4j/core/config/CompositeConfigurationTest.java | 6 -- .../apache/logging/log4j/core/impl/MutableLogEventTest.java | 1 - .../log4j/core/layout/CsvParameterLayoutAllAsyncTest.java | 1 - .../apache/logging/log4j/test/appender/BlockingAppender.java | 3 --- .../apache/logging/log4j/jmx/gui/ClientGuiJConsolePlugin.java | 2 -- 14 files changed, 35 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/706400b7/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java index bf49516..d018570 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicy.java @@ -16,13 +16,9 @@ */ package org.apache.logging.log4j.core.appender.rolling; -import java.lang.reflect.Method; - import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.PluginFactory; -import org.apache.logging.log4j.core.util.Loader; -import org.apache.logging.log4j.status.StatusLogger; /** * Triggers a rollover on every restart, but only if the file size is greater than zero. http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/706400b7/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java index 142b7e3..dc23555 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java @@ -17,10 +17,6 @@ package org.apache.logging.log4j.core.appender.rolling.action; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.channels.FileChannel; import java.nio.file.Files; import java.nio.file.Path; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/706400b7/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java index eab7044..629b9c9 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/builder/api/ConfigurationBuilder.java @@ -16,7 +16,6 @@ */ package org.apache.logging.log4j.core.config.builder.api; -import java.util.Map; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.Filter; import org.apache.logging.log4j.core.config.Configuration;
[25/40] logging-log4j2 git commit: Better lvar names.
Better lvar names. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/abd10103 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/abd10103 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/abd10103 Branch: refs/heads/LOG4J-1181 Commit: abd101035006f6b2d40448050b798c14d71fb234 Parents: 212a238 Author: ggregoryAuthored: Fri Jun 17 17:42:00 2016 -0700 Committer: ggregory Committed: Fri Jun 17 17:42:00 2016 -0700 -- .../log4j/core/appender/FileAppenderTest.java | 22 ++-- 1 file changed, 11 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/abd10103/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java index eea70ff..edfcd46 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java @@ -142,20 +142,20 @@ public class FileAppenderTest { final String classPath = System.getProperty("java.class.path"); final Integer count = 10; -final int processes = 3; -final Process[] process = new Process[processes]; -final ProcessBuilder[] builders = new ProcessBuilder[processes]; -for (int index = 0; index < processes; ++index) { +final int processeCount = 3; +final Process[] processes = new Process[processeCount]; +final ProcessBuilder[] builders = new ProcessBuilder[processeCount]; +for (int index = 0; index < processeCount; ++index) { builders[index] = new ProcessBuilder("java", "-cp", classPath, ProcessTest.class.getName(), "Process " + index, count.toString(), "true"); } -for (int index = 0; index < processes; ++index) { -process[index] = builders[index].start(); +for (int index = 0; index < processeCount; ++index) { +processes[index] = builders[index].start(); } -for (int index = 0; index < processes; ++index) { -final Process p = process[index]; +for (int index = 0; index < processeCount; ++index) { +final Process process = processes[index]; // System.out.println("Process " + index + " exited with " + p.waitFor()); -final InputStream is = p.getInputStream(); +final InputStream is = process.getInputStream(); final InputStreamReader isr = new InputStreamReader(is); final BufferedReader br = new BufferedReader(isr); String line; @@ -163,9 +163,9 @@ public class FileAppenderTest { System.out.println(line); } is.close(); -p.destroy(); +process.destroy(); } -verifyFile(count * processes); +verifyFile(count * processeCount); } private static void writer(final boolean lock, final int count, final String name) throws Exception {
[18/40] logging-log4j2 git commit: Statement unnecessarily nested within else clause.
Statement unnecessarily nested within else clause. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e962b162 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e962b162 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e962b162 Branch: refs/heads/LOG4J-1181 Commit: e962b162f8a5e9506f2dc69abde6331074d8c217 Parents: 706400b Author: ggregoryAuthored: Fri Jun 17 13:33:26 2016 -0700 Committer: ggregory Committed: Fri Jun 17 13:33:26 2016 -0700 -- .../log4j/core/config/ConfigurationFactory.java | 19 +-- .../logging/log4j/core/config/Configurator.java | 3 +-- .../config/composite/DefaultMergeStrategy.java | 3 +-- .../log4j/core/filter/CompositeFilter.java | 7 +++ .../log4j/core/pattern/NameAbbreviator.java | 3 +-- .../AsyncAppenderLog4j2LocationBenchmark.java| 2 -- .../perf/jmh/AsyncAppenderLogbackBenchmark.java | 1 - .../AsyncAppenderLogbackLocationBenchmark.java | 2 -- .../perf/jmh/AsyncLoggersLocationBenchmark.java | 2 -- .../jmh/MemoryHandlerJULLocationBenchmark.java | 2 -- .../perf/jmh/ThreadsafeDateFormatBenchmark.java | 6 ++ 11 files changed, 17 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e962b162/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java index 6497253..a5c54ac 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java @@ -408,16 +408,15 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory { return new CompositeConfiguration(configs); } return getConfiguration(configLocationStr); -} else { -for (final ConfigurationFactory factory : getFactories()) { -final String[] types = factory.getSupportedTypes(); -if (types != null) { -for (final String type : types) { -if (type.equals("*")) { -final Configuration config = factory.getConfiguration(name, configLocation); -if (config != null) { -return config; -} +} +for (final ConfigurationFactory factory : getFactories()) { +final String[] types = factory.getSupportedTypes(); +if (types != null) { +for (final String type : types) { +if (type.equals("*")) { +final Configuration config = factory.getConfiguration(name, configLocation); +if (config != null) { +return config; } } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e962b162/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java index 6de2506..e8286c1 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java @@ -126,9 +126,8 @@ public final class Configurator { uris.add(uri); } return initialize(name, loader, uris, externalContext); -} else { -return initialize(name, loader, NetUtils.toURI(configLocation), externalContext); } +return initialize(name, loader, NetUtils.toURI(configLocation), externalContext); } /** http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e962b162/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java
[31/40] logging-log4j2 git commit: LOG4J2-1437 ObjectMessage and ReusableObjectMessage now avoid calling toString() on auto-boxed primitive parameters
LOG4J2-1437 ObjectMessage and ReusableObjectMessage now avoid calling toString() on auto-boxed primitive parameters Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b225685f Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b225685f Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b225685f Branch: refs/heads/LOG4J-1181 Commit: b225685f30b08229b29a64c91d4e29d06a1724ee Parents: 6eff4fc Author: rpopmaAuthored: Sun Jun 19 12:55:22 2016 +0900 Committer: rpopma Committed: Sun Jun 19 12:55:22 2016 +0900 -- .../apache/logging/log4j/message/ObjectMessage.java | 14 ++ .../logging/log4j/message/ReusableObjectMessage.java | 14 ++ src/changes/changes.xml | 3 +++ 3 files changed, 31 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b225685f/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java index db8c31b..7ab9a48 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ObjectMessage.java @@ -64,6 +64,20 @@ public class ObjectMessage implements Message, StringBuilderFormattable { ((StringBuilderFormattable) obj).formatTo(buffer); } else if (obj instanceof CharSequence) { buffer.append((CharSequence) obj); +} else if (obj instanceof Integer) { // LOG4J2-1437 unbox auto-boxed primitives to avoid calling toString() +buffer.append(((Integer) obj).intValue()); +} else if (obj instanceof Long) { +buffer.append(((Long) obj).longValue()); +} else if (obj instanceof Double) { +buffer.append(((Double) obj).doubleValue()); +} else if (obj instanceof Boolean) { +buffer.append(((Boolean) obj).booleanValue()); +} else if (obj instanceof Character) { +buffer.append(((Character) obj).charValue()); +} else if (obj instanceof Short) { +buffer.append(((Short) obj).shortValue()); +} else if (obj instanceof Float) { +buffer.append(((Float) obj).floatValue()); } else { buffer.append(obj); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b225685f/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java index 21e9f98..fb3f176 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ReusableObjectMessage.java @@ -52,6 +52,20 @@ public class ReusableObjectMessage implements ReusableMessage { ((StringBuilderFormattable) obj).formatTo(buffer); } else if (obj instanceof CharSequence) { buffer.append((CharSequence) obj); +} else if (obj instanceof Integer) { // LOG4J2-1437 unbox auto-boxed primitives to avoid calling toString() +buffer.append(((Integer) obj).intValue()); +} else if (obj instanceof Long) { +buffer.append(((Long) obj).longValue()); +} else if (obj instanceof Double) { +buffer.append(((Double) obj).doubleValue()); +} else if (obj instanceof Boolean) { +buffer.append(((Boolean) obj).booleanValue()); +} else if (obj instanceof Character) { +buffer.append(((Character) obj).charValue()); +} else if (obj instanceof Short) { +buffer.append(((Short) obj).shortValue()); +} else if (obj instanceof Float) { +buffer.append(((Float) obj).floatValue()); } else { buffer.append(obj); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b225685f/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 84ff494..7f5eeaa 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -43,6 +43,9 @@ Fixed issue where AsyncAppenderQueueFullPolicyTest sometimes hangs. + +(GC) ObjectMessage and ReusableObjectMessage now avoid calling toString() on auto-boxed
[29/40] logging-log4j2 git commit: LOG4J2-1434 Update change log message
LOG4J2-1434 Update change log message Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/189c0d0b Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/189c0d0b Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/189c0d0b Branch: refs/heads/LOG4J-1181 Commit: 189c0d0b032dfc362d47f70622f473f9f4e4d0fb Parents: 945cea3 Author: rpopmaAuthored: Sat Jun 18 19:41:00 2016 +0900 Committer: rpopma Committed: Sat Jun 18 19:41:00 2016 +0900 -- src/changes/changes.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/189c0d0b/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index d5cf56a..84ff494 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -25,8 +25,8 @@ -Ensure that the thread-local StringBuilders used to format log events to text will not retain excessive -memory after a large message was logged. +Ensure that the thread-local StringBuilders used by Layouts to format log events to text will not +retain excessive memory after a large message was logged. Add "direct" option to ConsoleAppender for increased performance.
[15/40] logging-log4j2 git commit: Alawys use a block.
Alawys use a block. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2060b729 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2060b729 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2060b729 Branch: refs/heads/LOG4J-1181 Commit: 2060b729b7e95b4f1d09d632b45687383ba5e0fc Parents: ba07f0d Author: ggregoryAuthored: Fri Jun 17 10:28:47 2016 -0700 Committer: ggregory Committed: Fri Jun 17 10:28:47 2016 -0700 -- .../log4j/core/filter/AbstractFilterableTest.java | 12 +--- .../AbstractStringLayoutStringEncodingBenchmark.java| 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2060b729/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java index 86cce8d..4e0830d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/AbstractFilterableTest.java @@ -263,12 +263,18 @@ public class AbstractFilterableTest { @Override public boolean equals(final Object o) { -if (this == o) return true; -if (!(o instanceof EqualFilter)) return false; +if (this == o) { +return true; +} +if (!(o instanceof EqualFilter)) { +return false; +} final EqualFilter that = (EqualFilter) o; -if (key != null ? !key.equals(that.key) : that.key != null) return false; +if (key != null ? !key.equals(that.key) : that.key != null) { +return false; +} return true; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2060b729/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java -- diff --git a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java index 540c264..db01a17 100644 --- a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java +++ b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AbstractStringLayoutStringEncodingBenchmark.java @@ -188,7 +188,9 @@ public class AbstractStringLayoutStringEncodingBenchmark { private static long consume(final byte[] bytes) { long checksum = 0; -for (final byte b : bytes) checksum += b; +for (final byte b : bytes) { +checksum += b; +} return checksum; }
[06/40] logging-log4j2 git commit: Format nit
Format nit Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0dd55a0e Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0dd55a0e Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0dd55a0e Branch: refs/heads/LOG4J-1181 Commit: 0dd55a0ed56d7fc33cc1fd1a852bc03f6aca389e Parents: 1d6d31a Author: Matt SickerAuthored: Thu Jun 16 12:12:52 2016 -0500 Committer: Matt Sicker Committed: Thu Jun 16 12:12:52 2016 -0500 -- .../org/apache/logging/log4j/core/config/Configuration.java| 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0dd55a0e/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java index 900566d..678242c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configuration.java @@ -59,7 +59,7 @@ public interface Configuration extends Filterable { /** * Returns the Appender with the specified name. * - * @param The expected Appender type. + * @param The expected Appender type. * @param name The name of the Appender. * @return the Appender with the specified name or null if the Appender cannot be located. */ @@ -98,6 +98,7 @@ public interface Configuration extends Filterable { /** * Returns the root Logger. + * * @return the root Logger. */ LoggerConfig getRootLogger(); @@ -155,10 +156,11 @@ public interface Configuration extends Filterable { * * @return the {@code AsyncLoggerConfigDelegate} */ - AsyncLoggerConfigDelegate getAsyncLoggerConfigDelegate(); +AsyncLoggerConfigDelegate getAsyncLoggerConfigDelegate(); /** * Return the WatchManager. + * * @return the WatchManager. */ WatchManager getWatchManager();
[23/40] logging-log4j2 git commit: Merge remote-tracking branch 'origin/master'
Merge remote-tracking branch 'origin/master' Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/74ddb05e Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/74ddb05e Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/74ddb05e Branch: refs/heads/LOG4J-1181 Commit: 74ddb05ecf139dd7b3651cd7cd9c12d30b4c1844 Parents: a9b662e a9f89aa Author: rpopmaAuthored: Sat Jun 18 09:05:40 2016 +0900 Committer: rpopma Committed: Sat Jun 18 09:05:40 2016 +0900 -- .../log4j/core/pattern/NameAbbreviator.java | 28 1 file changed, 17 insertions(+), 11 deletions(-) --
[05/40] logging-log4j2 git commit: Make it easy to run from a command line with 'mvn -Dtest=FQCN test'
Make it easy to run from a command line with 'mvn -Dtest=FQCN test' Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/1d6d31ab Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/1d6d31ab Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/1d6d31ab Branch: refs/heads/LOG4J-1181 Commit: 1d6d31ab579a36c2e79c44fabcbc51e38435c7fa Parents: 8c22b37 Author: ggregoryAuthored: Wed Jun 15 22:36:42 2016 -0700 Committer: ggregory Committed: Wed Jun 15 22:36:42 2016 -0700 -- .../ConsoleAppenderAnsiStyleLayoutMain.java | 40 ++-- 1 file changed, 29 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/1d6d31ab/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java index 1952b37..860bf43 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ConsoleAppenderAnsiStyleLayoutMain.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.Configurator; +import org.junit.Test; /** * Shows how to use ANSI escape codes to color messages. Each message is printed to the console in color, but the rest @@ -29,27 +30,44 @@ import org.apache.logging.log4j.core.config.Configurator; * * Running from a Windows command line from the root of the project: * - * + * + * + * mvn -Dtest=org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain test + * + * or: * * java -classpath log4j-core\target\test-classes;log4j-core\target\classes;log4j-api\target\classes;%HOME%\.m2\repository\org\fusesource\jansi\jansi\1.11\jansi-1.11.jar; org.apache.logging.log4j.core.appender.ConsoleAppenderAnsiStyleLayoutMain log4j-core/target/test-classes/log4j2-console-style-ansi.xml * + * */ public class ConsoleAppenderAnsiStyleLayoutMain { -private static final Logger LOG = LogManager.getLogger(ConsoleAppenderAnsiStyleLayoutMain.class); - public static void main(final String[] args) { +new ConsoleAppenderAnsiStyleLayoutMain().test(args); +} + +/** + * This is a @Test method to make it easy to run from a command line with {@code mvn -Dtest=FQCN test} + */ +@Test +public void test() { +test(null); +} + +public void test(final String[] args) { // System.out.println(System.getProperty("java.class.path")); -final String config = args.length == 0 ? "target/test-classes/log4j2-console-style-ansi.xml" : args[0]; +final String config = args == null || args.length == 0 ? "target/test-classes/log4j2-console-style-ansi.xml" +: args[0]; final LoggerContext ctx = Configurator.initialize(ConsoleAppenderAnsiMessagesMain.class.getName(), config); +final Logger logger = LogManager.getLogger(ConsoleAppenderAnsiStyleLayoutMain.class); try { -LOG.fatal("Fatal message."); -LOG.error("Error message."); -LOG.warn("Warning message."); -LOG.info("Information message."); -LOG.debug("Debug message."); -LOG.trace("Trace message."); -LOG.error("Error message.", new IOException("test")); +logger.fatal("Fatal message."); +logger.error("Error message."); +logger.warn("Warning message."); +logger.info("Information message."); +logger.debug("Debug message."); +logger.trace("Trace message."); +logger.error("Error message.", new IOException("test")); } finally { Configurator.shutdown(ctx); }
[10/40] logging-log4j2 git commit: Format nits.
Format nits. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ea23f07f Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ea23f07f Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ea23f07f Branch: refs/heads/LOG4J-1181 Commit: ea23f07f2c742f7bfb271310f672a35b610196ab Parents: 906f510 Author: ggregoryAuthored: Thu Jun 16 15:51:00 2016 -0700 Committer: ggregory Committed: Thu Jun 16 15:51:00 2016 -0700 -- .../org/apache/logging/log4j/message/ParameterizedMessage.java| 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ea23f07f/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java index d9b9ea5..4638fb5 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/message/ParameterizedMessage.java @@ -46,14 +46,17 @@ public class ParameterizedMessage implements Message, StringBuilderFormattable { * Prefix for errors. */ public static final String ERROR_PREFIX = ParameterFormatter.ERROR_PREFIX; + /** * Separator for errors. */ public static final String ERROR_SEPARATOR = ParameterFormatter.ERROR_SEPARATOR; + /** * Separator for error messages. */ public static final String ERROR_MSG_SEPARATOR = ParameterFormatter.ERROR_MSG_SEPARATOR; + /** * Suffix for errors. */
[02/40] logging-log4j2 git commit: Fix system property description in manual
Fix system property description in manual Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e262edac Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e262edac Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e262edac Branch: refs/heads/LOG4J-1181 Commit: e262edac33c418040f18cf32953b22f9c8711a97 Parents: 2efb076 Author: Matt SickerAuthored: Tue Jun 14 10:37:44 2016 -0500 Committer: Matt Sicker Committed: Tue Jun 14 10:37:44 2016 -0500 -- src/site/xdoc/manual/configuration.xml.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e262edac/src/site/xdoc/manual/configuration.xml.vm -- diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm index 6fb4900..1276a0e 100644 --- a/src/site/xdoc/manual/configuration.xml.vm +++ b/src/site/xdoc/manual/configuration.xml.vm @@ -1861,7 +1861,7 @@ public class AwesomeTest { AsyncLogger.WaitStrategy - Sleep + Timeout See Async Logger System Properties for details.
[04/40] logging-log4j2 git commit: [LOG4J2-1433] Update Jansi from 1.11 to 1.13.
[LOG4J2-1433] Update Jansi from 1.11 to 1.13. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8c22b37d Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8c22b37d Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8c22b37d Branch: refs/heads/LOG4J-1181 Commit: 8c22b37df52f39abc4830127ce0f8ea1aa408ed2 Parents: b3f45fb Author: ggregoryAuthored: Wed Jun 15 21:05:04 2016 -0700 Committer: ggregory Committed: Wed Jun 15 21:05:04 2016 -0700 -- pom.xml | 2 +- src/changes/changes.xml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8c22b37d/pom.xml -- diff --git a/pom.xml b/pom.xml index 85f9309..29d49b8 100644 --- a/pom.xml +++ b/pom.xml @@ -385,7 +385,7 @@ org.fusesource.jansi jansi -1.11 +1.13 true http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8c22b37d/src/changes/changes.xml -- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index c329c52..b76cce7 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -48,6 +48,9 @@ Update Jackson from 2.7.4 to 2.7.5. + +Update Jansi from 1.11 to 1.13. +
[14/40] logging-log4j2 git commit: Add final modifier to lvar.
Add final modifier to lvar. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ba07f0d3 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ba07f0d3 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ba07f0d3 Branch: refs/heads/LOG4J-1181 Commit: ba07f0d3935faccbefb567ac6237170ea1846f5c Parents: be2393e Author: ggregoryAuthored: Fri Jun 17 10:27:36 2016 -0700 Committer: ggregory Committed: Fri Jun 17 10:27:36 2016 -0700 -- .../java/org/apache/logging/log4j/util/Unbox.java | 4 ++-- .../appender/AsyncAppenderQueueFullPolicyTest.java | 2 +- .../rolling/OnStartupTriggeringPolicyTest.java | 16 .../rolling/RandomRollingAppenderOnStartupTest.java | 6 +++--- .../rolling/RollingAppenderOnStartupTest.java | 6 +++--- .../appender/rolling/RollingAppenderSizeTest.java | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ba07f0d3/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java -- diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java index d0bb16f..acf154c 100644 --- a/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/Unbox.java @@ -75,14 +75,14 @@ public class Unbox { ringBuffer.set(array); current.set(new int[1]); } -int[] index = current.get(); +final int[] index = current.get(); final StringBuilder result = array[MASK & index[0]++]; result.setLength(0); return result; } public boolean isBoxedPrimitive(final StringBuilder text) { -StringBuilder[] array = ringBuffer.get(); +final StringBuilder[] array = ringBuffer.get(); if (array == null) { return false; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ba07f0d3/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java index a5adf83..b4da847 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/AsyncAppenderQueueFullPolicyTest.java @@ -58,7 +58,7 @@ public class AsyncAppenderQueueFullPolicyTest { blockingAppender = (BlockingAppender) context.getAppender("Block"); asyncAppender = (AsyncAppender) context.getAppender("Async"); -Field field = AsyncAppender.class.getDeclaredField("asyncQueueFullPolicy"); +final Field field = AsyncAppender.class.getDeclaredField("asyncQueueFullPolicy"); field.setAccessible(true); policy = new CountingAsyncQueueFullPolicy(); field.set(asyncAppender, policy); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ba07f0d3/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java index bfec1c8..ad1e5c7 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/rolling/OnStartupTriggeringPolicyTest.java @@ -41,22 +41,22 @@ public class OnStartupTriggeringPolicyTest { @Test public void testPolicy() throws Exception { -Configuration configuration = new DefaultConfiguration(); -Path target = Paths.get(TARGET_FILE); -Path rolled = Paths.get(ROLLED_FILE); +final Configuration configuration = new DefaultConfiguration(); +final Path target = Paths.get(TARGET_FILE); +final Path rolled = Paths.get(ROLLED_FILE); Files.deleteIfExists(target); Files.deleteIfExists(rolled); -InputStream is = new ByteArrayInputStream(TEST_DATA.getBytes("UTF-8")); +final InputStream is = new
[26/40] logging-log4j2 git commit: Use try-with-resources.
Use try-with-resources. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c80735fa Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c80735fa Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c80735fa Branch: refs/heads/LOG4J-1181 Commit: c80735fadd6c6442fa76d938da4263104de8a98b Parents: abd1010 Author: ggregoryAuthored: Fri Jun 17 17:44:30 2016 -0700 Committer: ggregory Committed: Fri Jun 17 17:44:30 2016 -0700 -- .../log4j/core/appender/FileAppenderTest.java | 17 +++-- 1 file changed, 7 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c80735fa/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java -- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java index edfcd46..8cf5f10 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/FileAppenderTest.java @@ -139,15 +139,14 @@ public class FileAppenderTest { @Test @Ignore public void testMultipleVMs() throws Exception { - final String classPath = System.getProperty("java.class.path"); final Integer count = 10; final int processeCount = 3; final Process[] processes = new Process[processeCount]; final ProcessBuilder[] builders = new ProcessBuilder[processeCount]; for (int index = 0; index < processeCount; ++index) { -builders[index] = new ProcessBuilder("java", "-cp", classPath, ProcessTest.class.getName(), "Process " -+ index, count.toString(), "true"); +builders[index] = new ProcessBuilder("java", "-cp", classPath, ProcessTest.class.getName(), +"Process " + index, count.toString(), "true"); } for (int index = 0; index < processeCount; ++index) { processes[index] = builders[index].start(); @@ -155,14 +154,12 @@ public class FileAppenderTest { for (int index = 0; index < processeCount; ++index) { final Process process = processes[index]; // System.out.println("Process " + index + " exited with " + p.waitFor()); -final InputStream is = process.getInputStream(); -final InputStreamReader isr = new InputStreamReader(is); -final BufferedReader br = new BufferedReader(isr); -String line; -while ((line = br.readLine()) != null) { -System.out.println(line); +try (final BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream( { +String line; +while ((line = br.readLine()) != null) { +System.out.println(line); +} } -is.close(); process.destroy(); } verifyFile(count * processeCount);
[27/40] logging-log4j2 git commit: Refactor some more, inspired by Gary: use Strategy design pattern and delegate to Strategy instance.
Refactor some more, inspired by Gary: use Strategy design pattern and delegate to Strategy instance. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/db47cde3 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/db47cde3 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/db47cde3 Branch: refs/heads/LOG4J-1181 Commit: db47cde3dee34601accbb6d6e23c04b07560bb25 Parents: c80735f Author: rpopmaAuthored: Sat Jun 18 13:49:47 2016 +0900 Committer: rpopma Committed: Sat Jun 18 13:49:47 2016 +0900 -- .../log4j/core/pattern/NameAbbreviator.java | 97 +--- 1 file changed, 42 insertions(+), 55 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/db47cde3/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java index a0eaa1b..bb43d9e 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java @@ -142,7 +142,6 @@ public abstract class NameAbbreviator { * * @param original the text to abbreviate, may not be null. * @param destination StringBuilder to write the result to - * @return The abbreviated String. */ public abstract void abbreviate(final String original, final StringBuilder destination); @@ -176,23 +175,48 @@ public abstract class NameAbbreviator { * 2. Retain a given number of parts starting from the end - called RETAIN */ private enum Strategy { - -DROP { -@Override -int getMinCount() { -return 0; +DROP(0) { +void abbreviate(final int count, final String original, final StringBuilder destination) { +// If a path does not contain enough path elements to drop, none will be dropped. +int start = 0; +int nextStart; +for (int i = 0; i < count; i++) { +nextStart = original.indexOf('.', start); +if (nextStart == -1) { +destination.append(original); +return; +} +start = nextStart + 1; +} +destination.append(original, start, original.length()); } }, -RETAIN { -@Override -int getMinCount() { -return 1; +RETAIN(1) { +void abbreviate(final int count, final String original, final StringBuilder destination) { +// We subtract 1 from 'len' when assigning to 'end' to avoid out of +// bounds exception in return r.substring(end+1, len). This can happen if +// precision is 1 and the category name ends with a dot. +int end = original.length() - 1; + +for (int i = count; i > 0; i--) { +end = original.lastIndexOf('.', end - 1); +if (end == -1) { +destination.append(original); +return; +} +} +destination.append(original, end + 1, original.length()); } }; - -abstract int getMinCount(); -}; +final int minCount; + +Strategy(final int minCount) { +this.minCount = minCount; +} + +abstract void abbreviate(final int count, final String original, final StringBuilder destination); +} /** * Maximum number of path elements to output. @@ -211,8 +235,7 @@ public abstract class NameAbbreviator { * @param strategy drop or retain */ public MaxElementAbbreviator(final int count, final Strategy strategy) { -final int minCount = strategy.getMinCount(); -this.count = count < minCount ? minCount : count; +this.count = Math.max(count, strategy.minCount); this.strategy = strategy; } @@ -220,47 +243,11 @@ public abstract class NameAbbreviator { * Abbreviate name. * * @param original The String to abbreviate. - * @param
[32/40] logging-log4j2 git commit: LOG4J2-1434 added missing closing tag
LOG4J2-1434 added missing closing tag Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/52e769f8 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/52e769f8 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/52e769f8 Branch: refs/heads/LOG4J-1181 Commit: 52e769f8a52d9a94330a5bf6c54e01bb28ef6ae1 Parents: b225685 Author: rpopmaAuthored: Sun Jun 19 13:23:06 2016 +0900 Committer: rpopma Committed: Sun Jun 19 13:23:06 2016 +0900 -- src/site/xdoc/manual/configuration.xml.vm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/52e769f8/src/site/xdoc/manual/configuration.xml.vm -- diff --git a/src/site/xdoc/manual/configuration.xml.vm b/src/site/xdoc/manual/configuration.xml.vm index 65843e3..ac386ed 100644 --- a/src/site/xdoc/manual/configuration.xml.vm +++ b/src/site/xdoc/manual/configuration.xml.vm @@ -1989,7 +1989,7 @@ public class AwesomeTest { log4j.layoutStringBuilder.maxSize 2048 This property determines the maximum size of the thread-local reusable StringBuilders - used to format the log event to text by Layouts that extend AbstractStringLayout. + used to format the log event to text by Layouts that extend AbstractStringLayout. log4j.unbox.ringbuffer.size
[24/40] logging-log4j2 git commit: Add missing Javadoc tags.
Add missing Javadoc tags. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/212a2384 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/212a2384 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/212a2384 Branch: refs/heads/LOG4J-1181 Commit: 212a23845d93467efc1c5db722ed340ed806fdf0 Parents: 74ddb05 Author: ggregoryAuthored: Fri Jun 17 17:37:37 2016 -0700 Committer: ggregory Committed: Fri Jun 17 17:37:37 2016 -0700 -- .../logging/log4j/core/appender/MemoryMappedFileManager.java | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/212a2384/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java index cfb5a08..6038038 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/MemoryMappedFileManager.java @@ -300,6 +300,8 @@ public class MemoryMappedFileManager extends OutputStreamManager { * @param append Append to existing file or truncate. * @param force forces the memory content to be written to the storage device on every event * @param regionLength length of the mapped region + * @param advertiseURI the URI to use when advertising the file + * @param layout The layout. */ public FactoryData(final boolean append, final boolean force, final int regionLength, final String advertiseURI, final Layout layout) {
[21/40] logging-log4j2 git commit: Refactor conditional into method call on an enum.
Refactor conditional into method call on an enum. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a9f89aae Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a9f89aae Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a9f89aae Branch: refs/heads/LOG4J-1181 Commit: a9f89aae788a439147e2d7eef82641a45da8d6d8 Parents: 9b16256 Author: ggregoryAuthored: Fri Jun 17 17:00:42 2016 -0700 Committer: ggregory Committed: Fri Jun 17 17:00:42 2016 -0700 -- .../log4j/core/pattern/NameAbbreviator.java | 28 1 file changed, 17 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a9f89aae/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java index 1011937..a0eaa1b 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NameAbbreviator.java @@ -176,8 +176,22 @@ public abstract class NameAbbreviator { * 2. Retain a given number of parts starting from the end - called RETAIN */ private enum Strategy { -DROP, -RETAIN + +DROP { +@Override +int getMinCount() { +return 0; +} +}, +RETAIN { +@Override +int getMinCount() { +return 1; +} +}; + +abstract int getMinCount(); + }; /** @@ -197,19 +211,11 @@ public abstract class NameAbbreviator { * @param strategy drop or retain */ public MaxElementAbbreviator(final int count, final Strategy strategy) { -final int minCount = getMinCount(strategy); +final int minCount = strategy.getMinCount(); this.count = count < minCount ? minCount : count; this.strategy = strategy; } -private int getMinCount(final Strategy strategy) { -if (Strategy.DROP == strategy) { -return 0; -} else { // Strategy.RETAIN -return 1; -} -} - /** * Abbreviate name. *
[38/40] logging-log4j2 git commit: Add missing methods
Add missing methods Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/2b713565 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/2b713565 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/2b713565 Branch: refs/heads/LOG4J-1181 Commit: 2b713565687be3b46d1eb1e6a44ddc7e403122d1 Parents: 88044f3 Author: Mikael StåldalAuthored: Sun Jun 19 21:13:22 2016 +0200 Committer: Mikael Ståldal Committed: Sun Jun 19 21:13:22 2016 +0200 -- .../scala/org/apache/logging/log4j/scala/Logger.scala | 10 -- .../scala/org/apache/logging/log4j/scala/Logger.scala | 10 -- 2 files changed, 16 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2b713565/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala -- diff --git a/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala b/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala index 783073f..7284f84 100644 --- a/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala +++ b/log4j-api-scala_2.10/src/main/scala/org/apache/logging/log4j/scala/Logger.scala @@ -290,7 +290,9 @@ class Logger(val delegate: ExtendedLogger) { def isEnabled(level: Level, marker: Marker): Boolean = delegate.isEnabled(level, marker) + // TODO fix FQCN for flow logging + def traceEntry(): EntryMessage = delegate.traceEntry() def traceEntry(params: Any*): EntryMessage = @@ -298,12 +300,16 @@ class Logger(val delegate: ExtendedLogger) { def traceEntry(message: Message): EntryMessage = delegate.traceEntry(message) - def traceExit[R](result: R): R = delegate.traceExit(result) - def traceExit(): Unit = delegate.traceExit() + def traceExit[R](result: R): R = delegate.traceExit(result) + def traceExit(entryMessage: EntryMessage): Unit = delegate.traceExit(entryMessage) + def traceExit[R](entryMessage: EntryMessage, result: R): R = delegate.traceExit(entryMessage, result) + + def traceExit[R](message: Message, result: R): R = delegate.traceExit(message, result) + def throwing[T <: Throwable](t: T): T = delegate.throwing(t) def throwing[T <: Throwable](level: Level, t: T): T = delegate.throwing(level, t) http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/2b713565/log4j-api-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala -- diff --git a/log4j-api-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala b/log4j-api-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala index 783073f..7284f84 100644 --- a/log4j-api-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala +++ b/log4j-api-scala_2.11/src/main/scala/org/apache/logging/log4j/scala/Logger.scala @@ -290,7 +290,9 @@ class Logger(val delegate: ExtendedLogger) { def isEnabled(level: Level, marker: Marker): Boolean = delegate.isEnabled(level, marker) + // TODO fix FQCN for flow logging + def traceEntry(): EntryMessage = delegate.traceEntry() def traceEntry(params: Any*): EntryMessage = @@ -298,12 +300,16 @@ class Logger(val delegate: ExtendedLogger) { def traceEntry(message: Message): EntryMessage = delegate.traceEntry(message) - def traceExit[R](result: R): R = delegate.traceExit(result) - def traceExit(): Unit = delegate.traceExit() + def traceExit[R](result: R): R = delegate.traceExit(result) + def traceExit(entryMessage: EntryMessage): Unit = delegate.traceExit(entryMessage) + def traceExit[R](entryMessage: EntryMessage, result: R): R = delegate.traceExit(entryMessage, result) + + def traceExit[R](message: Message, result: R): R = delegate.traceExit(message, result) + def throwing[T <: Throwable](t: T): T = delegate.throwing(t) def throwing[T <: Throwable](level: Level, t: T): T = delegate.throwing(level, t)
logging-log4j2 git commit: LOG4J2-1434 Ensure that the thread-local StringBuilder in GelfLayout will not retain excessive memory after a large message was logged.
Repository: logging-log4j2 Updated Branches: refs/heads/master 13b453ce5 -> aed2298e3 LOG4J2-1434 Ensure that the thread-local StringBuilder in GelfLayout will not retain excessive memory after a large message was logged. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/aed2298e Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/aed2298e Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/aed2298e Branch: refs/heads/master Commit: aed2298e3272164804266a7ed7a47b8b6dc3ee00 Parents: 13b453c Author: Mikael StåldalAuthored: Sun Jun 19 11:08:06 2016 +0200 Committer: Mikael Ståldal Committed: Sun Jun 19 11:08:06 2016 +0200 -- .../logging/log4j/core/layout/GelfLayout.java | 37 +--- 1 file changed, 24 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/aed2298e/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java -- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java index 13a14f9..098d18c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java @@ -16,6 +16,17 @@ */ package org.apache.logging.log4j.core.layout; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Map; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.GZIPOutputStream; + import org.apache.logging.log4j.Level; import org.apache.logging.log4j.core.Layout; import org.apache.logging.log4j.core.LogEvent; @@ -32,17 +43,6 @@ import org.apache.logging.log4j.status.StatusLogger; import org.apache.logging.log4j.util.StringBuilderFormattable; import org.apache.logging.log4j.util.Strings; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.Map; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.GZIPOutputStream; - /** * Lays out events in the Graylog Extended Log Format (GELF) 1.1. * @@ -231,8 +231,12 @@ public final class GelfLayout extends AbstractStringLayout { JsonUtils.quoteAsString(((CharSequence)message), builder); } else if (gcFree && message instanceof StringBuilderFormattable) { final StringBuilder messageBuffer = getMessageStringBuilder(); -((StringBuilderFormattable)message).formatTo(messageBuffer); -JsonUtils.quoteAsString(messageBuffer, builder); +try { +((StringBuilderFormattable) message).formatTo(messageBuffer); +JsonUtils.quoteAsString(messageBuffer, builder); +} finally { +returnMessageStringBuilder(messageBuffer); +} } else { JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), builder); } @@ -253,6 +257,13 @@ public final class GelfLayout extends AbstractStringLayout { return result; } +private void returnMessageStringBuilder(StringBuilder stringBuilder) { +if (stringBuilder.length() > MAX_STRING_BUILDER_SIZE) { +stringBuilder.setLength(MAX_STRING_BUILDER_SIZE); +stringBuilder.trimToSize(); +} +} + private CharSequence toNullSafeString(final CharSequence s) { return s == null ? Strings.EMPTY : s; }