With sl4fj if I want to construct a string message there is a nice approach which makes use of substitutions. For instance, it might be something like:
logger.info("Action {} occured on object {}.", objectA.getAction(), objectB);
If there are more than a few substitutions required then it is something like:
logger.info("Action {} occured on object {} with outcome {}.",
new Object[]{objectA.getAction(), objectB, outcome});
My question is: Is there a generic way for me to create a string (and not just a slf4j log message)? Something like:
String str = someMethod("Action {} occured on object {}.", objectA.getAction(), objectB);
or
String str = someMethod("Action {} occured on object {} with outcome {}.",
new Object[]{objectA.getAction(), objectB, outcome});
If it is in the standard Java library, what would that "someMethod" be?