在启动类里可以这样配置
String path = System.getProperty("APP_HOME");
if (path == null) {
path = System.getProperty("user.dir");
if (path == null) {
System.out.println("警告:TOOL_HOME 启动属性没有正确设置,可能影响日志记录!");
return;
}
path = path + "/target/项目名mbd-epaper";
}
BASE_PATH = path.replaceAll("\\\\", "/") + "/";
BASE_PATH = BASE_PATH.replaceAll("//", "/");
if (File.separator.equals("\\")){
BASE_PATH = BASE_PATH.replaceAll("/", "\\\\");
} else {
BASE_PATH = BASE_PATH.replaceAll("\\\\", "/");
对于log4j.xml配置文件的读取,可以利用其下的类PropertyConfigurator.configure(logConfigPath);