qos-ch / slf4j

Simple Logging Facade for Java
http://www.slf4j.org
MIT License
2.32k stars 980 forks source link

docs: add docs for error with arguments and throwable #396

Closed liran2000 closed 6 months ago

liran2000 commented 6 months ago

It is common action to log an error message with arguments, together with the exception.
With current error method declaration and javadoc, it is hard to tell how to do this.
This PR adds documentation to the method for explaining it.

Example usage:

String arg1 = "v1";
String arg2 = "v2";
log.error("arg1: {}, arg2: {}", arg1, arg2, new Exception("error message"));
liran2000 commented 6 months ago

hi @ceki would you be able to review this ?

ceki commented 6 months ago

@liran2000 Thank you for this PR. Have you seen the comments at the top of the Logger class which mention handling of exceptions? Also the handling of a Throwable passed as last argument is expected to be the same for all printing methods, not just error(..,)

liran2000 commented 6 months ago

@liran2000 Thank you for this PR. Have you seen the comments at the top of the Logger class which mention handling of exceptions? Also the handling of a Throwable passed as last argument is expected to be the same for all printing methods, not just error(..,)

I see now. if references to the FAQ, where it is written, without a full-link. For developers at IDE, commonly looking at the method, it can be less clear, and even if developer had the chance to look at the comments at the top of the Logger class, he then need to search for a link and follow it.

thanks for your response.