I need to add debug points in my javaagent. I am having my premain method in one class and AgentClassFileTransformer in another class. Since my organization use following approach which use org.apache.commons.logging package I also tried to use that method.
private static final Log log = LogFactory.getLog(InstrumentingAgent.class);
But, if I add only the log4j.properties file to the resource folder of the project, it prints the logs from the class with premain method.
But for the class which implements ClassFileTransformer it says no appenders can be found. But, again if I add the commons-logging.properties file to the same resources folder, then it'll print all the logs required in the console. (Even if I use the logger of type log4j as follows, it still says no appenders can be found for Transformer class)
Commons-logging.properties
org.apache.commons.logging.Log = org.apache.commons.logging.impl.Log4JLogger
Warning for Transformer class
log4j:WARN No appenders could be found for logger (InstrumentationClassTransformer).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
In my case I'll be adding on debug level logs in my agent. But when the agent run with a product it shouldn't print debug logs on the console. In terms of log4j I have read about setting the log level of the logger using setLevel(Log.level) method. But since I am using commons-logging's LogFactory it doesn't give any option to set the level also. So I would like to have some suggestions on how to get over this situation.
How can I get this to work? Is it something that can be achieved or do I need to change the logging mechanism?
Update 1
I have even added the package name, as mentioned by madhawa, but still it doesn't print logs of ClassFileTransformer.
log4j.rootLogger=DEBUG, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.logger.org.javaagent.instrumentation=DEBUG