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

Handling multi-line log messages #404

Closed
metacubed opened this issue May 7, 2020 · 5 comments
Closed

Handling multi-line log messages #404

metacubed opened this issue May 7, 2020 · 5 comments
Milestone

Comments

@metacubed
Copy link
Contributor

When configuring handling of newlines in log messages, a useful addition would be the ability to output the "message" field as a JSON array, instead of a JSON string.

For example, with either of these logging statements:

logger.error("first line{}second line", System.lineSeparator());
// or
logger.error("first line\nsecond line");
// or
logger.error("first line\r\nsecond line");

The output would be consistent:

{
    "message": [
        "first line",
        "second line"
    ],
    ...
}

This would provide an unambiguous parsing format on the target system instead of relying on the source platform's newline representation.

@philsttr
Copy link
Collaborator

While this is not directly supported by the existing JsonProviders, you could disable the output of the current message field, and implement this functionality in a custom JsonProvider

Alternatively, would you be interested in submitting a PR for modifying the existing MessageJsonProvider to support this? You could modify the MessageJsonProvider to have an option to split the message on newlines.

@metacubed
Copy link
Contributor Author

@philsttr, thanks for pointing me to the right class. I'll try adding a new option to the MessageJsonProvider.

@metacubed
Copy link
Contributor Author

@philsttr, are you ok with adding the JUnitParams library to this project? It uses the same license, Apache 2.0 - 2004.

It is also recommended by JUnit: Parameterized tests - See also

@philsttr
Copy link
Collaborator

I'd rather not, since I don't see much activity on that project, and the last release was close to 3 years ago.

@metacubed
Copy link
Contributor Author

metacubed commented May 24, 2020

@philsttr, no worries, I haven't used it.

I just submitted a PR #413 to add the multi-line splitting option - please review when convenient.

@philsttr philsttr added this to the 6.4 milestone May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants