////
    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.
////
[id=log4j.gc.enableDirectEncoders]
== `log4j.gc.enableDirectEncoders`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_GC_ENABLE_DIRECT_ENCODERS`
| Type          | `boolean`
| Default value | `true`
|===

If `true`, garbage-aware layouts will directly encode log events into
https://docs.oracle.com/en/java/javase/{java-target-version}/docs/api/java.base/java/nio/ByteBuffer.html[`ByteBuffer`]s
provided by appenders.

This prevents allocating temporary `String` and `char[]` instances.

[id=log4j.gc.encoderByteBufferSize]
== `log4j.gc.encoderByteBufferSize`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_GC_ENCODER_BYTE_BUFFER_SIZE`
| Type          | `int`
| Default value | `8192`
|===

The size in bytes of the
https://docs.oracle.com/en/java/javase/{java-target-version}/docs/api/java.base/java/nio/ByteBuffer.html[`ByteBuffer`]s
stored in `ThreadLocal` fields by layouts and
link:../javadoc/log4j-core/org/apache/logging/log4j/core/layout/StringBuilderEncoder.html[`StringBuilderEncoder`]s.

This setting is only used if <<log4j.gc.enableDirectEncoders>> is set to `true`.

[id=log4j.gc.encoderCharBufferSize]
== `log4j.gc.encoderCharBufferSize`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_GC_ENCODER_CHAR_BUFFER_SIZE`
| Type          | `int`
| Default value | `4096`
|===

The size in ``char``s of the
https://docs.oracle.com/en/java/javase/{java-target-version}/docs/api/java.base/java/nio/ByteBuffer.html[`ByteBuffer`]s
stored in `ThreadLocal` fields
link:../javadoc/log4j-core/org/apache/logging/log4j/core/layout/StringBuilderEncoder.html[`StringBuilderEncoder`]s.

This setting is only used if <<log4j.gc.enableDirectEncoders>> is set to `true`.

// tag::api[]
[id=log4j.gc.initialReusableMsgSize]
== `log4j.gc.initialReusableMsgSize`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_GC_INITIAL_REUSABLE_MSG_SIZE`
| Type          | `int`
| Default value | `128`
|===

In GC-free mode, this property determines the initial size of the reusable ``StringBuilder``s used by
{log4j2-url}/javadoc/log4j-api/org/apache/logging/log4j/message/ReusableMessage.html[`ReusableMessages`]
for formatting purposes.

[id=log4j.gc.maxReusableMsgSize]
== `log4j.gc.maxReusableMsgSize`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_GC_MAX_REUSABLE_MSG_SIZE`
| Type          | `int`
| Default value | `518`
|===

In GC-free mode, this property determines the maximum size of the reusable ``StringBuilder``s used by
{log4j2-url}/javadoc/log4j-api/org/apache/logging/log4j/message/ReusableMessage.html[`ReusableMessages`]
for formatting purposes.

The default value allows is equal to `2 &times; (2 &times; log4j.initialReusableMsgSize + 2) + 2` and allows the
``StringBuilder`` to be resized twice by the current JVM resize algorithm.
// end::api[]

[id=log4j.gc.layoutStringBuilderMaxSize]
== `log4j.gc.layoutStringBuilderMaxSize`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_GC_LAYOUT_STRING_BUILDER_MAX_SIZE`
| Type          | `int`
| Default value | `2048`
|===

This property determines the maximum size of the reusable ``StringBuilder``s used to format
link:../javadoc/log4j-core/org/apache/logging/log4j/core/LogEvent.html[`LogEvent`]s.

// tag::api[]

[id=log4j2.unboxRingbufferSize]
== `log4j2.unboxRingbufferSize`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_UNBOX_RINGBUFFER_SIZE`
| Type          | `int`
| Default value | `32`
|===

The
{log4j2-url}/javadoc/log4j-api/org/apache/logging/log4j/util/Unbox.html[`Unbox`]
utility class can be used by users to format primitive values without incurring in the boxing allocation cost.

This property specifies the maximum number of primitive arguments to a log message that will be cached and usually does not need to be changed.

// end::api[]

[id=log4j.recycler.capacity]
== `log4j.recycler.capacity`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_RECYCLER_CAPACITY`
| Type          | `int`
| Default value | `2C` rounded to the next power of `2` (`C` denoting the number of available processors)
|===

Denotes the buffer capacity for a recycler.
For a queueing recycler, it corresponds to the queue size.
For a thread local recycler, it corresponds to the per-thread buffer size.

If an invalid capacity is provided (i.e., if the capacity is zero or negative), the default value will be used.

[id=log4j.recycler.factory]
== `log4j.recycler.factory`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_RECYCLER_FACTORY`
| Type          | `String`
| Default value | `null`
|===

If provided, available recycler factory providers will be sorted in order, and the first one whose name matching with this property value will be used.

If missing or the selection fails, the default will be used.

[id=log4j.recycler.conversant.spinPolicy]
== `log4j.recycler.conversant.spinPolicy`

[cols="1h,5"]
|===
| Env. variable | `LOG4J_RECYCLER_CONVERSANT_SPIN_POLICY`

| Type
| https://javadoc.io/doc/com.conversantmedia/disruptor/latest/com.conversantmedia.disruptor/com/conversantmedia/util/concurrent/SpinPolicy.html[`SpinPolicy`]

| Default value
| https://javadoc.io/doc/com.conversantmedia/disruptor/latest/com.conversantmedia.disruptor/com/conversantmedia/util/concurrent/SpinPolicy.html#WAITING[`WAITING`]
|===

Denotes the strategy adopted by the Conversant Disruptor, when the queue is fully used.
This configuration property is only used if the
xref:manual/garbagefree.adoc#recyclers-conversant[`conversant-disrutor` recycler]
is used.

See https://javadoc.io/doc/com.conversantmedia/disruptor/latest/com.conversantmedia.disruptor/com/conversantmedia/util/concurrent/SpinPolicy.html[Conversant Disruptor Javadoc] for details.