Reputation: 55
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?
Upvotes: 0
Views: 2318
Reputation: 16736
Generics have nothing to do with this.
At runtime, a logger by the name of x.y.z.GenericClass
(x.y.z
being the package in which GenericClass
is 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=true
to your server initialization parameters and give it a try.
Upvotes: 2