I have an abstract class Parent, with 2 subclasses A and B. Parent has one static method called do(). I am wondering if there is a way for that static method to add log info in Logger for class A when it's called as A.do() and log B when it's called as B.do(). The usual
protected final Logger LOGGER = Logger.getLogger(getClass());
won't work as do() is a static method so Logger needs to be static as well, but the getClass() method is obviously not static.
Thanks.
private final static Logger LOGGER = Logger.getLogger(A.class);
Every class having its own logger: specifying the class is fine.
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