This repository has been archived by the owner on Apr 23, 2024. It is now read-only.
Modified LogglyBatchAppender to Insert Newline Characters (0x0A) Between Each Log Event #21
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ality to DiscardingRollingOutputStream along with unit tests for all new methods
… stream prior to each new log event if the stream is non-empty and does not currently end with a newline. This is necessary when shipping JSON events with the ch.qos.logback.contrib.jackson.JacksonJsonFormatter, as it does not append newline characters, but loggly expects them to break individual batch members into separate events.
… into four separate tests, each with a single assert statement
…riginal author used.
…d a comment explaining its value
tony19
added a commit
that referenced
this pull request
Mar 6, 2014
tony19
added a commit
that referenced
this pull request
Mar 6, 2014
This fixes a problem where every batch sent to loggly was seen as a single log event instead of the individual events within the batch.
Fixed in d51377c |
tony19
added a commit
that referenced
this pull request
Mar 6, 2014
Make sure messages end with new-line char to delimit individual log events within the batch sent to loggly. Fixes #21
Re-implemented in simpler way: 56de824 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch addresses #17
When using the LogglyBatchAppender with the ch.qos.logback.contrib.json.classic.JsonLayout layout class, new line characters (0x0A) are not inserted into the buffer between each JSON object. This causes Loggly to interpret the entire batch request as a single log event, instead of as n distinct events.
My patch inserts a newline character prior to each log event if the stream is currently non-empty and does not have a newline character in the last position. This means that it will be backward compatible with other layout managers that add the newline character automatically, but will fix the issues with the JSON layout manager.
The new methods that were added to DiscardingRollingOutputStream have full test coverage, and I have confirmed that LogglyBatchAppender correctly inserts newlines by using Charles to sniff traffic during ad-hoc testing against a live Loggly instance. It should be possible to add automatic unit testing for this file once the @ignore annotation is removed from the existing test cases.
A Note about Diffs: The diff of the code appears to have replaced every line in each of the two files that I edited - this is probably do to some kind of formatting change. I didn't actually rewrite all of the code.