I am trying to implement log4j logging for MyTest
class. The package structure for the code is as described using the code under. Currently my log4j.properties is placed under the resources of trial
package.
I do get the logs sometimes but at times the debugger displays "log4j:WARN No appenders could be found for logger." So I end up with :
- Where should I place the log4j.properties to get the logs consistently in MyTest?
- Can the same project have more than one log4j.properties in different packages?
- How is the log4j properties associated by debugger/compiler with a class calling it?
BasicPage.class
package com.trial.pages;
public class BasicPage{
protected static final Logger pageLogger = Logger.getLogger(BasicPage.class);
<some code goes here>
}
FirstPage.class
package com.trial.pages.mobile;
import package com.trial.pages;
public class FirstPage extends BasicPage {
public void pageMethod() {
pageLogger.info("These are logs from the Pages.");
}
}
BasicTest.class
package com.core.data;
public class BasicTest{
protected static final Logger testLogger = Logger.getLogger(BasicTest.class);
<some code goes here>
}
MyTest.class
package com.trial.tests.mobile;
import com.trial.pages.mobile.FirstPage;
import com.core.data.BasicTest;
public class MyTest extends BasicTest{
public void someMethod(){
testLogger.info("These are the logs from the test activities.");
new FirstPage.pageMethod();
}
}