When trying to add log4j logger to a Generic class, it does not generate logs.
This is the code used.
public class GenericClass<K extends Serializable, V extends Serializable> extends ... {
public static Logger log = Logger.getLogger(GenericClass.class.getName());
I am guessing the reason this code fails is because the class is not instantiated till runtime and the plain name that i have given no more resolves to the newly generated class.
Is there a way that generic classes can be logged at all?
Generics have nothing to do with this.
At runtime, a logger by the name of
x.y.z.GenericClass(x.y.zbeing the package in whichGenericClassis located). If nothing is logged, then it’s either because your application isn’t logging anything, or your Log4J configuration is faulty.To decide which one is true, add
-Dlog4j.debug=trueto your server initialization parameters and give it a try.