如果 Tomcat 下部署多个项目的时候 logPath 会出现项目之间串用问题,所以启用 customLogPath 名字

This commit is contained in:
thinkgem
2021-04-15 18:57:36 +08:00
parent 3a770f2818
commit c9dd006597

View File

@@ -218,6 +218,10 @@ public class PropertiesUtils {
*/ */
private static Logger initLogger(){ private static Logger initLogger(){
String logPath = null; String logPath = null;
if (StringUtils.isNotBlank(System.getProperty("customLogPath"))){
// 如果 Tomcat 下部署多个项目的时候 logPath 会出现项目之间串用问题,所以启用 customLogPath 名字
logPath = System.getProperty("customLogPath");
}else{
try { try {
// 获取当前classes目录 // 获取当前classes目录
logPath = ResourceUtils.getResource("/").getFile().getPath(); logPath = ResourceUtils.getResource("/").getFile().getPath();
@@ -230,9 +234,8 @@ public class PropertiesUtils {
if (new File(classesLogPath).exists()){ if (new File(classesLogPath).exists()){
logPath = classesLogPath; logPath = classesLogPath;
} }
if (StringUtils.isBlank(System.getProperty("logPath"))){
System.setProperty("logPath", FileUtils.path(logPath));
} }
System.setProperty("logPath", FileUtils.path(logPath));
return LoggerFactory.getLogger(PropertiesUtils.class); return LoggerFactory.getLogger(PropertiesUtils.class);
} }