[jira] [Updated] (LOG4J2-2256) GelfLayout does not allow to truncate short message to arbitrary length

2018-02-20 Thread Hugo Veillette (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4J2-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hugo Veillette updated LOG4J2-2256:
---
Description: 
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable. 
Note that StringBuilderFormattable can only be truncated to a value greater 
than or equal to 1024 bytes. So we cannot rely on this (maybe it should be 
treated as a separate defect)

The outcome leads to large amount of data stored in the short message field 
which impacts performance, storage and indexing.

Proposed enhancement:
Short message: Provide ability to use a pattern layout (which will inherit the 
ability to set length) and/or add the ability to set arbitrary size through the 
gelf layout attribute
Full message: Should contain the plain message with the stack trace (the stack 
trace part was already covered properly)

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}

  was:
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable (which can be truncated to a value greater or 
equal to 1024 bytes).

The outcome leads to large amount of data stored in the short message the 
appenders which ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the layout definition to 
set arbitrary length for the short message.

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}


> GelfLayout does not allow to truncate short message to arbitrary length
> ---
>
> Key: LOG4J2-2256
> URL: https://issues.apache.org/jira/browse/LOG4J2-2256
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Layouts
>Affects Versions: 2.10.0
>Reporter: Hugo Veillette
>Priority: Critical
>
> Hi, 
> using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
> value of the "short_message" field to an arbitrary size for message type 
> other than StringBuilderFormattable. 
> Note that StringBuilderFormattable can only be truncated to a value greater 
> than or equal to 1024 bytes. So we cannot rely on this (maybe it should be 
> treated as a separate defect)
> The outcome leads to large amount of data stored 

[jira] [Updated] (LOG4J2-2256) GelfLayout does not allow to truncate short message to arbitrary length

2018-02-20 Thread Hugo Veillette (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4J2-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hugo Veillette updated LOG4J2-2256:
---
Description: 
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable (which can be truncated to a value greater or 
equal to 1024 bytes).

The outcome leads to large amount of data stored in the short message the 
appenders which ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the layout definition to 
set arbitrary length for the short message.

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}

  was:
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable.

The outcome leads to large amount of data duplicated through the appenders 
which ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the layout definition to 
set arbitrary length for the short message.

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}


> GelfLayout does not allow to truncate short message to arbitrary length
> ---
>
> Key: LOG4J2-2256
> URL: https://issues.apache.org/jira/browse/LOG4J2-2256
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Layouts
>Affects Versions: 2.10.0
>Reporter: Hugo Veillette
>Priority: Critical
>
> Hi, 
> using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
> value of the "short_message" field to an arbitrary size for message type 
> other than StringBuilderFormattable (which can be truncated to a value 
> greater or equal to 1024 bytes).
> The outcome leads to large amount of data stored in the short message the 
> appenders which ends up hurting performance, storage and network.
> Proposed enhancement would be to add an attribute in the layout definition to 
> set arbitrary length for the short message.
> Here is the detail of 2.10.0 implementation.
> {code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
> builder.append("\"short_message\":\"");
> final Message message = event.getMessage();
> if (message instanceof CharSequence) {
> 

[jira] [Updated] (LOG4J2-2256) GelfLayout does not allow to truncate short message to arbitrary length

2018-02-19 Thread Hugo Veillette (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4J2-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hugo Veillette updated LOG4J2-2256:
---
Description: 
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable.

The outcome leads to large amount of data duplicated through the appenders 
which ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the layout definition to 
set arbitrary length for the short message.

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}

  was:
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable.

The outcome leads to duplicate large amount of data through the appenders which 
ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the layout definition to 
set arbitrary length for the short message.

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}


> GelfLayout does not allow to truncate short message to arbitrary length
> ---
>
> Key: LOG4J2-2256
> URL: https://issues.apache.org/jira/browse/LOG4J2-2256
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Layouts
>Affects Versions: 2.10.0
>Reporter: Hugo Veillette
>Priority: Critical
>
> Hi, 
> using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
> value of the "short_message" field to an arbitrary size for message type 
> other than StringBuilderFormattable.
> The outcome leads to large amount of data duplicated through the appenders 
> which ends up hurting performance, storage and network.
> Proposed enhancement would be to add an attribute in the layout definition to 
> set arbitrary length for the short message.
> Here is the detail of 2.10.0 implementation.
> {code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
> builder.append("\"short_message\":\"");
> final Message message = event.getMessage();
> if (message instanceof CharSequence) {
> JsonUtils.quoteAsString(((CharSequence)message), builder);
> } else if (gcFree && message instanceof StringBuilderFormattable) {
> final 

[jira] [Updated] (LOG4J2-2256) GelfLayout does not allow to truncate short message to arbitrary length

2018-02-19 Thread Hugo Veillette (JIRA)

 [ 
https://issues.apache.org/jira/browse/LOG4J2-2256?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Hugo Veillette updated LOG4J2-2256:
---
Description: 
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable.

The outcome leads to duplicate large amount of data through the appenders which 
ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the layout definition to 
set arbitrary length for the short message.

Here is the detail of 2.10.0 implementation.
{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}
{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}

  was:
Hi, 

using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
value of the "short_message" field to an arbitrary size for message type other 
than StringBuilderFormattable. 

The outcome leads to duplicate large amount of data through the appenders which 
ends up hurting performance, storage and network.

Proposed enhancement would be to add an attribute in the short message to set 
arbitrary length for the short message. 

Here is the  detail of 2.10.0 implementation. 

{code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
builder.append("\"short_message\":\"");
final Message message = event.getMessage();
if (message instanceof CharSequence) {
JsonUtils.quoteAsString(((CharSequence)message), builder);
} else if (gcFree && message instanceof StringBuilderFormattable) {
final StringBuilder messageBuffer = getMessageStringBuilder();
try {
((StringBuilderFormattable) message).formatTo(messageBuffer);
JsonUtils.quoteAsString(messageBuffer, builder);
} finally {
trimToMaxSize(messageBuffer);
}
} else {

JsonUtils.quoteAsString(toNullSafeString(message.getFormattedMessage()), 
builder);
}
{code}

{code:java|title="org.apache.logging.log4j.core.layout.AbstractStringLayout"}
protected static final int MAX_STRING_BUILDER_SIZE = 
Math.max(DEFAULT_STRING_BUILDER_SIZE,
size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
protected static void trimToMaxSize(final StringBuilder stringBuilder) {
StringBuilders.trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
}
{code}


> GelfLayout does not allow to truncate short message to arbitrary length
> ---
>
> Key: LOG4J2-2256
> URL: https://issues.apache.org/jira/browse/LOG4J2-2256
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Layouts
>Affects Versions: 2.10.0
>Reporter: Hugo Veillette
>Priority: Critical
>
> Hi, 
> using the GelfLayout provided in Log4j2 core, we are unable to truncate the 
> value of the "short_message" field to an arbitrary size for message type 
> other than StringBuilderFormattable.
> The outcome leads to duplicate large amount of data through the appenders 
> which ends up hurting performance, storage and network.
> Proposed enhancement would be to add an attribute in the layout definition to 
> set arbitrary length for the short message.
> Here is the detail of 2.10.0 implementation.
> {code:java|title="org.apache.logging.log4j.core.layout.GelfLayout"}
> builder.append("\"short_message\":\"");
> final Message message = event.getMessage();
> if (message instanceof CharSequence) {
> JsonUtils.quoteAsString(((CharSequence)message), builder);
> } else if (gcFree && message instanceof StringBuilderFormattable) {
> final