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

JsonEncoder produces invalid json when suppressing throwable #866

Open
bhurwitz-yottaa opened this issue Oct 8, 2024 · 1 comment
Open
Assignees
Milestone

Comments

@bhurwitz-yottaa
Copy link

Using some combinations of the configurations for the JsonEncoder that do not include all the available properties, the log entries will generate invalid json (dangling comma before closing brace).

Example that fails:

        <encoder class="ch.qos.logback.classic.encoder.JsonEncoder">
            <withLoggerName>true</withLoggerName>
            <withFormattedMessage>true</withFormattedMessage>
            <withMessage>false</withMessage>
            <withSequenceNumber>false</withSequenceNumber>
            <withContext>false</withContext>
            <withNanoseconds>false</withNanoseconds>
            <withMDC>false</withMDC>
            <withArguments>false</withArguments>
            <withTimestamp>true</withTimestamp>
            <withThrowable>false</withThrowable>
        </encoder>

You can work around this by not including <withThrowable>false</withThrowable> but this forces the user to log unwanted characters.

There are multiple spots in the code for inclusion of the properties that naively append a "," after their inclusion, this is part of the problem.

@ceki ceki self-assigned this Oct 8, 2024
@ceki ceki added this to the 1.5.10 milestone Oct 8, 2024
@ceki
Copy link
Member

ceki commented Oct 8, 2024

@bhurwitz-yottaa Fixed in commit cbbd820

@ceki ceki added the DONE label Oct 8, 2024
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