Property objectMessageAsJsonObject="true" in log42.xml (jsonLayout) doesn't work with netty server (webflux). With tomcat server, it works

Viewed 120

I am setting my application logs to be painted in JSON format. In the log4j2.xml file, I have the following configuration for my appender:

<JsonLayout complete="false" compact="true" eventEol="true" includeTimeMillis="true" includeStacktrace="true" objectMessageAsJsonObject="true">
</JsonLayout>

With the property objectMessageAsJsonObject = "true", I am stating that if an attribute of a printed log is an object, paint it as JSON.

My problem is that it doesn't paint it as json, it paints it as json but in string form:

Example: (Look at the message attribute)

{"timeMillis":1637633364457,"thread":"reactor-http-epoll-1","level":"DEBUG","loggerName":"es.example.controller.HelloWorldController","message":"{\"name\":\"Josué\"}" ... }

I am using webflux and the embedded server it uses is netty. I have observed that if I exclude the netty server and include the tomcat server, the attributes that are objects are correctly painted as JSON.

In the pom.xml I am excluding the spring-boot-starter-logging artifact and adding the spring-boot-starter-log4j2 dependency, as indicated in all guides.

Anyone know how to get it to work properly with the netty server? Thanks in advance.

0 Answers
Related