2 :
: log4j 2, NetBeans TestNG.
, .
( log4j2.xml, src/), . , . , , - .
- :
public class someTestClass {
static final Logger log=LogManager.getLogger("test.someTestClass");
......
@Test
public void SomeMethod(){
System.setProperty("log4j.configurationFile", "resources/log4j2_conf.xml");
log.trace("This will not show because the default logging level is ERROR
and the resources/log4j2_conf.xml is not loaded");
}
, , System.setProperty, log4j ( Logger =...)
, @BeforeClass :
public class someTestClass {
Logger log;
@BeforeClass
public void setLogger(){
SetEnv.SetEnvironment();
log = LogManager.getLogger("TestRealClientRealServer");
}
......
@Test
public void SomeMethod(){
log.trace("This will show, because in log4j2_conf.xml
the root level is set to TRACE");
}
}
BTW, / , "test" log4j setup.
,