Skip to content

LOG4J2-2892 - Add support for newline delimited messages in GelfLayout#394

Merged
rgoers merged 2 commits intoapache:masterfrom
jakluk:LOG4J2-2892
Aug 16, 2020
Merged

LOG4J2-2892 - Add support for newline delimited messages in GelfLayout#394
rgoers merged 2 commits intoapache:masterfrom
jakluk:LOG4J2-2892

Conversation

@jakluk
Copy link
Copy Markdown

@jakluk jakluk commented Aug 5, 2020

A pull request for issue https://issues.apache.org/jira/browse/LOG4J2-2892.

This PR adds ability to delimit Graylog Extended Log Format (GELF) messages with a newline. It can be useful when you want to append messages in the Graylog format into a file, or when you have to feed the messages into a consumer which supports only newlines as a delimiter. The documentation of GELF only specifies usage of a NULL delimiter and doesn't discourage from using some other. It also requires that newlines inside the message body must be escaped, so multi-line stack traces shouldn't be an issue.

New optional boolean parameter "includeNewLineDelimiter" is introduced to GelfLayout, nothing changes for current users if they decide not to use it.

Copy link
Copy Markdown
Member

@rgoers rgoers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've sanity tested what you are trying to do and am OK with the change but please add the requested items.


@Test
public void testLayoutNewLineDelimiter() throws Exception {
testCompressedLayout(CompressionType.OFF, false, true, HOSTNAME, false, true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a test that includes the stack trace.

@@ -222,37 +224,42 @@ private void testCompressedLayout(final CompressionType compressionType, final b

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any code added to validate that the newline is present.

@jakluk
Copy link
Copy Markdown
Author

jakluk commented Aug 7, 2020

@rgoers Thank you for the quick review. There was no test whether the null byte delimiter is present so I've added that one as well.

@rgoers rgoers merged commit dcad4a8 into apache:master Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants