I am using apache logger api for logging the messages, warnings, errors and exception. I find two methods in logger api to catch the logging name.
public static Logger getLogger(String name)
public static Logger getLogger(Class clazz)
among those which is best methods to choose for performance?
Typically, logger instances are created as static fields. So this call is only made once per class per JVM, and the performance difference will be in the noise.
It’s hard to see a good reason to do otherwise. If you are going to call the one that takes a class, you are making one logger per class, and so you can’t possibly be sitting in a loop.
So you can expect the one that takes a class to be faster, but you will be hard-pressed to measure the difference in a realistic situation.