I have a java project(note:- its not a web project).I am using log4j to log messages.
Presently the steps I am following to do it are as follows:
Created a log4j.properties file at project level.
Declared Logger logger = Logger.getLogger(MyClass.class);
Then configured properties using -> PropertyConfigurator.configure("log4j.properties");
Then used logger.debug("message"); to log my messages.
But the problem I felt with this approach is that I have to do the same in all the classes in my project i.e. from all the steps starting from declaring Logger logger
.
Is there any way so that I can configure my logger variable at a single place only once in my project and then just use the declared variable of logger to log the messages?