Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSONLayout class #13

Merged
merged 2 commits into from
Oct 23, 2019
Merged

Add JSONLayout class #13

merged 2 commits into from
Oct 23, 2019

Conversation

bblough
Copy link
Contributor

@bblough bblough commented Oct 12, 2019

This layout will format the LoggingEvent information such the date,
logger, level, message, and location information, as well as the values
in the MDC and NDC, into valid JSON. This is useful for consumption
by elasticsearch or other log tools.

This layout will format the LoggingEvent information such the date,
logger, level, message, and location information, as well as the values
in the MDC and NDC, into valid JSON.  This is useful for consumption
by elasticsearch.
Copy link
Contributor

@ams-tschoening ams-tschoening left a comment

Choose a reason for hiding this comment

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

Thanks for the work. Would be great if you can look at the minor changes I mentioned. Besides that, did you consider something like pretty-printing of the output or do you think it's not worth it? Might it even break your use case?

src/main/cpp/jsonlayout.cpp Outdated Show resolved Hide resolved
src/main/cpp/jsonlayout.cpp Outdated Show resolved Hide resolved
src/main/cpp/jsonlayout.cpp Outdated Show resolved Hide resolved
src/main/cpp/jsonlayout.cpp Show resolved Hide resolved
src/main/cpp/jsonlayout.cpp Outdated Show resolved Hide resolved
src/main/cpp/jsonlayout.cpp Outdated Show resolved Hide resolved
@bblough
Copy link
Contributor Author

bblough commented Oct 13, 2019

For my use case, I think single-line log entries are preferred. But I can see how other use cases might benefit from pretty-printed output. I'll add it as a option.

* Fix misplaced comment
* Add guard clauses to remove unnecessary if blocks
* Remove unnecessary return statement
* Move LocationInfo serialization to separate function
* Add "pretty-print" option.
@bblough
Copy link
Contributor Author

bblough commented Oct 13, 2019

Pretty-print option added. All changes pushed.

@ams-tschoening
Copy link
Contributor

Thanks for changing things, but I additionally ran into problems getting the new layout to compile in case the WCHAR_T-API is used and your tests failed on my Windows as well. The first problem could easily be changed by using LOG4CXX_STR everywhere and the latter by using LOG4CXX_EOL instead of \n. HTMLLayout seemed to have done the same.

Would be great if you could have a look at my newly created branch containing your PR and my additional fixes, if things still work for you.

https://github.com/apache/logging-log4cxx/tree/ghpr_13

@bblough
Copy link
Contributor Author

bblough commented Oct 22, 2019

Ah, sorry about that. Thanks for fixing it. I've just compiled and tested here and it still works for me.

@asfgit asfgit merged commit 203b4a8 into apache:master Oct 23, 2019
@ams-tschoening
Copy link
Contributor

That's good news, so I merged everything to master. Thanks for the contribution.

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.

None yet

3 participants