[slf4j-dev] [JIRA] Updates for SLF4J-600: .addKeyValue() log-requests are not getting logged

slf4j developers list slf4j-dev at qos.ch
Sat Sep 23 08:44:00 CEST 2023


SLF4J / SLF4J-600 [Resolved]
.addKeyValue() log-requests are not getting logged

==============================

Here's what changed in this issue in the last few minutes.


There is 1 comment.


View or comment on issue using this link
https://jira.qos.ch/browse/SLF4J-600

==============================
 1 comment
------------------------------

Ralph Goers on 23/Sep/23 6:33

I just took a look at the code and it is adding the key/value pairs to the ThreadContextMap instead of building a MapMessage. The SLF4J documentation says

{code:java}
The key-value pair variant of the API stores the key-value pairs as separates objects. The default implementation currently in the org.slf4j.Logger class prefixes key-value pairs to the message. Logging backends are free and are even encouraged to offer a more customizable behaviour.
{code}

Given that the API says that what happens with key/value pairs is implementation specific I'd hesitate to classify this as an error. Adding %X to your pattern should cause them to be included. I can't speak to what EcsLayout does as that is not provided by Log4j but JsonTemplateLayout would allow the items to be included in the JSON. 

Despite this I will open a discussion on the Log4j dev list to determine if what we are doing is really the correct behavior.


==============================
 This message was sent by Atlassian Jira (v9.6.0#960000-sha1:a3ee8af)



More information about the slf4j-dev mailing list