The main reason to require String instead of Object for a message type is to avoid ambiguity in method signatures.
Accepts the following signatures:
1) debug(Object)
then when you write
debug("hello", new Exception("world"));
it is unclear whether option 2 or option 3 should be used.
In any case, with the existing SLF4J API, you can always write:
logger.debug("{}", yourObject);
If the basic structure of logging is login, then your object will be available to all participants without changes. The other logging framework does not support message options, so SLF4J must format the message before invoking the base structure.
source share