-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codeslf4jAffects SLF4J integrationAffects SLF4J integration
Description
Description
See https://jira.qos.ch/browse/SLF4J-600. It seems SLF4J added an addKeyValue method to its fluent API. When this is called the data is not being added to a MapMessage as it needs to be.
Configuration
Version: 2.20.0
Logs
When SLF4J routes to Log4j the output looks like:
[19.09.2023 19:25:51,248] [INFO ] - slf4j2-with-log4j - Measure times:
None of the key/value pairs are present.
Reproduction
The code has
private static final Logger LOG = LoggerFactory.getLogger("PERFORMANCE");
...
LOG.atInfo().setMessage("slf4j2-with-log4j - Measure times:")
.addKeyValue("myDocId", documentId)
.addKeyValue("myInitExtractorInMs", createFormExtractor)
.addKeyValue("myvalidatedDocumentInMs", validatedDocument)
.addKeyValue("myreadPageInMs", readPage)
.addKeyValue("mytransformInfosInMs", transformInfos)
.log();
To work properly this needs to translate into
StringMapMessage log4jMap = new StringMapMessage()
.with("message", "direct log4j implementation - Measure times:")
.with("myDocId", documentId)
.with("myInitExtractorInMs", createFormExtractor)
.with("myvalidatedDocumentInMs", validatedDocument)
.with("myreadPageInMs", readPage)
.with("mytransformInfosInMs", transformInfos);
LogManager.getLogger("PERFORMANCE").info(log4jMap);
Note that IMO it would be better for Log4j's LogBuilder add support for addKeyValue and internally populate a MapMessage.
yvasyliev, jkwatson-verta and dacr
Metadata
Metadata
Assignees
Labels
bugIncorrect, unexpected, or unintended behavior of existing codeIncorrect, unexpected, or unintended behavior of existing codeslf4jAffects SLF4J integrationAffects SLF4J integration
Type
Projects
Status
To triage