To log errors for a given class, I'm accessing the class name like so: Is this a 'good' way to return the class name as a String, so it can be used for logging?
private static final String CLASS_NAME = MyClass.class.getName();
logger.error("Error occurred in "+CLASS_NAME);
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles;
...
private final static Logger LOG =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
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