在这里我们试着添加配置文件。
另外,我们需要注意的是2.0版本中的配置只能为Xml和Json。
测试代码为:
package com.foo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Bar {
static Logger logger = LogManager.getLogger(Bar.class.getName());
public boolean doIt() {
logger.entry(); //Log entry to a method
logger.error("Did it again!"); //Log a message object with the ERROR level
logger.exit(); //Log exit from a method
return false;
}
}
import com.foo.Bar;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class MyApp {
// Define a static logger variable so that it references the
// Logger instance named "MyApp".
private static Logger logger = LogManager.getLogger(MyApp.class.getName());
public static void main(String[] args) {