LOG4J2-1296 made initial and max StringBuilder size configurable, changed default of max to 518
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b3342152 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b3342152 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b3342152 Branch: refs/heads/gelf-layout-gc-free Commit: b334215219f2fe853ce2bce2ab2366bc744a6106 Parents: 50c7683 Author: rpopma <rpo...@apache.org> Authored: Tue Mar 15 08:34:19 2016 +1100 Committer: rpopma <rpo...@apache.org> Committed: Tue Mar 15 08:34:19 2016 +1100 ---------------------------------------------------------------------- .../logging/log4j/core/async/RingBufferLogEvent.java | 9 +++++++-- src/site/xdoc/manual/configuration.xml.vm | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b3342152/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java index e4c135a..d4669f7 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java @@ -32,6 +32,7 @@ import org.apache.logging.log4j.core.util.Constants; import org.apache.logging.log4j.message.Message; import org.apache.logging.log4j.message.ReusableMessage; import org.apache.logging.log4j.message.SimpleMessage; +import org.apache.logging.log4j.util.PropertiesUtil; import org.apache.logging.log4j.util.Strings; import com.lmax.disruptor.EventFactory; @@ -46,8 +47,12 @@ public class RingBufferLogEvent implements LogEvent { public static final Factory FACTORY = new Factory(); private static final long serialVersionUID = 8462119088943934758L; - private static final int INITIAL_REUSABLE_MESSAGE_SIZE = 128; - private static final int MAX_REUSABLE_MESSAGE_SIZE = 128 * 2 + 2; // resized once from 128 (s=s*2+2) + private static final int INITIAL_REUSABLE_MESSAGE_SIZE = size("log4j.initialReusableMsgSize", 128); + private static final int MAX_REUSABLE_MESSAGE_SIZE = size("log4j.maxReusableMsgSize", (128 * 2 + 2) * 2 + 2); + + private static int size(final String property, final int defaultValue) { + return PropertiesUtil.getProperties().getIntegerProperty(property, defaultValue); + } /** * Creates the events that will be put in the RingBuffer. http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b3342152/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 f1e72f0..18d53b2 100644 --- a/src/site/xdoc/manual/configuration.xml.vm +++ b/src/site/xdoc/manual/configuration.xml.vm @@ -1903,6 +1903,18 @@ public class AwesomeTest { <td>org.apache.logging.log4j.message. DefaultFlowMessageFactory</td> <td>Default flow message factory used by Loggers.</td> </tr> + <tr> + <td>log4j.initialReusableMsgSize</td> + <td>128</td> + <td>In GC-free mode, this property determines the initial size of the reusable StringBuilders where the message + text is formatted and potentially passed to background threads.</td> + </tr> + <tr> + <td>log4j.maxReusableMsgSize</td> + <td>518</td> + <td>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.</td> + </tr> </table> </subsection>