I am beginning to use SLF4J for logging and the first thing that strikes to me is the following piece of code
public class MyClass
{
private static final logger = org.slf4j.LoggerFactory.getLogger(MyClass.class)
}
What is the design principle or logic of using the class as an argument to obtain an instance of the logger ?
The result of this is that each logging statement generated by that logger contains the name of the class. You want to do this to:
The above is a very common pattern in logging. Note however that you don't just have to provide a class, but you can provide your own string instead, and thus arbitrarily categorise your messages yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With