Skip to content

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

@nbardiuk

Description

@nbardiuk

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions