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

tryJson drops logs when JSON object has a field with null value #702

Closed
nbardiuk opened this issue Nov 17, 2021 · 2 comments · Fixed by #704
Closed

tryJson drops logs when JSON object has a field with null value #702

nbardiuk opened this issue Nov 17, 2021 · 2 comments · Fixed by #704
Assignees
Labels

Comments

@nbardiuk
Copy link

nbardiuk commented Nov 17, 2021

Describe the bug
tryJson drops logs when JSON object has a field with a null value

To Reproduce
Steps to reproduce the behavior:

  1. Use this logback.xml configuration...
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
            <providers>
                <pattern>
                    <pattern>
            {
              "event":"#tryJson{%message}"
            }
          </pattern></pattern>
            </providers>
        </encoder>
    </appender>
  1. Execute this logger statement
logger.debug("{\"field\":null}");
  1. See error, or unexpected output
    the log is empty

Expected behavior
The log output should contain

"event":{"field":null}

Additional context
This used to work with logstash-logback-encoder 6.6

  • logstash-logback-encoder 7.0
  • logback version 1.2.7
  • jackson version 2.13.0
  • java version OpenJDK 64-Bit Server VM 11.0.11+9
@nbardiuk nbardiuk changed the title tryJson drops logs when JSON object has a key with null value tryJson drops logs when JSON object has a field with null value Nov 17, 2021
@brenuart
Copy link
Collaborator

brenuart commented Nov 17, 2021

Hi @nbardiuk ,

Thanks for the report. I can confirm this is a bug (a regression) introduced in 7.0
If you register a status listener and print logback statuses on the console (see here) you will notice an exception is thrown while trying to serialise the JSON object. The problem occurs when trying to serialise a complex JsonNode (Object, Map or Array) with one its children elements being null.

I'm sorry but there is no workaround for this issue. We are working on it. Stay tuned...

PS: how urgent is it for you to get this solved? Are you just giving 7.0 a try or do you want to roll it into production?

@nbardiuk
Copy link
Author

We tried to use the new version and have noticed the issue.
As a workaround, we can use the previous version, which works great for us.
Thank you for looking into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants