[slf4j-dev] Planned/possible fluent API change
Ceki Gülcü
ceki at qos.ch
Fri Mar 18 15:11:07 CET 2022
Hello all,
In SLF4J-526, Adrian Shum proposed to modify the fluent API.
Currently, to emit a debug message with two parameters, one has to write
the following
logger.atDebug()
.addArgument(country).addArgument(oldTemp).addArgument(newTemp)
.log("Temperature of {} rise from {} to {}");
He proposes that the API be changed to
logger.atDebug()
.message("Temperature of {} rise from {} to {}" )
.arg(country).arg(oldTemp).arg(newTemp).log();
I think his suggestion makes sense with one inconvenience. In case the
user forgets to call the no-argument log() method, then nothing will
happen, i.e. no logging will occur. With the current API, it is harder
for the user to forget the log(String) method containing the message
content.
Before going forward with Adrian's proposal or not, I would like to
receive input by interested parties.
Best regards,
[1] https://jira.qos.ch/browse/SLF4J-526
--
Ceki Gülcü
More information about the slf4j-dev
mailing list