SAP/cf-java-logging-support

Log4j2 JsonPatternLayout might generate invalid JSON in v3.5.3

KarstenSchnitter opened this issue · 1 comments

With v3.5.3 come a new feature, that fields with default value are by default not emitted in the generated log messages. For the cf-java-logging-support-log4j2, this can result in invalid JSON messages. The feature can be disabled with the XML attribute sendDefaultValues="true.

<Configuration
   status="warn" strict="true"
   packages="com.sap.hcp.cf.log4j2.converter,com.sap.hcp.cf.log4j2.layout">
	<Appenders>
        <Console name="STDOUT-JSON" target="SYSTEM_OUT" follow="true">
            <JsonPatternLayout charset="utf-8" sendDefaultValues="true" />
        </Console>
        <Console name="STDOUT" target="SYSTEM_OUT" follow="true">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} [%mdc] - %msg%n"/>
        </Console>
	</Appenders>
  <Loggers>
     <Root level="${LOG_ROOT_LEVEL:-WARN}">
        <!-- Use 'STDOUT' instead for human-readable output -->
        <AppenderRef ref="STDOUT-JSON" />
     </Root>
  	 <!-- request metrics are reported using INFO level, so make sure the instrumentation loggers are set to that level -->
     <Logger name="com.sap.hcp.cf" level="INFO"/>
  </Loggers>
</Configuration>

the proposed mitigation is ineffective. I will provide a fix ASAP.