fix #2673 add logSuffix

This commit is contained in:
Shinsuke Sugaya 2022-08-15 22:06:51 +09:00
parent 29f1154e2e
commit 5a97261ce6
4 changed files with 18 additions and 3 deletions

View file

@ -276,7 +276,7 @@ public class CrawlJob extends ExecJob {
addSystemProperty(cmdList, Constants.FESS_CONF_PATH, null, null);
cmdList.add("-Dfess." + getExecuteType() + ".process=true");
cmdList.add("-Dfess.log.path=" + (logFilePath != null ? logFilePath : systemHelper.getLogFilePath()));
addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
addSystemProperty(cmdList, "fess.log.name", getLogName("fess"), getLogName(StringUtil.EMPTY));
if (logLevel == null) {
addSystemProperty(cmdList, "fess.log.level", null, null);
} else {

View file

@ -27,6 +27,7 @@ import java.util.Properties;
import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codelibs.core.lang.StringUtil;
import org.codelibs.core.timer.TimeoutManager;
import org.codelibs.core.timer.TimeoutTask;
import org.codelibs.fess.Constants;
@ -49,6 +50,8 @@ public abstract class ExecJob {
protected String logLevel;
protected String logSuffix = StringUtil.EMPTY;
protected List<String> jvmOptions = new ArrayList<>();
protected String lastaEnv;
@ -86,6 +89,11 @@ public abstract class ExecJob {
return this;
}
public ExecJob logSuffix(final String logSuffix) {
this.logSuffix = logSuffix.trim().replaceAll("\\s", "_");
return this;
}
public ExecJob timeout(final int timeout) {
this.timeout = timeout;
return this;
@ -196,4 +204,11 @@ public abstract class ExecJob {
throw new IORuntimeException(e);
}
}
protected String getLogName(final String logPrefix) {
if (logSuffix.length() > 0) {
return logPrefix + "-" + getExecuteType() + "-" + logSuffix;
}
return logPrefix + "-" + getExecuteType();
}
}

View file

@ -172,7 +172,7 @@ public class GenerateThumbnailJob extends ExecJob {
cmdList.add("-Dfess.log.path=" + logFilePath);
addSystemProperty(cmdList, Constants.FESS_VAR_PATH, null, null);
addSystemProperty(cmdList, Constants.FESS_THUMBNAIL_PATH, null, null);
addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
addSystemProperty(cmdList, "fess.log.name", getLogName("fess"), getLogName(StringUtil.EMPTY));
if (logLevel != null) {
cmdList.add("-Dfess.log.level=" + logLevel);
}

View file

@ -157,7 +157,7 @@ public class SuggestJob extends ExecJob {
logFilePath = value != null ? value : new File(targetDir, "logs").getAbsolutePath();
}
cmdList.add("-Dfess.log.path=" + logFilePath);
addSystemProperty(cmdList, "fess.log.name", "fess-" + getExecuteType(), "-" + getExecuteType());
addSystemProperty(cmdList, "fess.log.name", getLogName("fess"), getLogName(StringUtil.EMPTY));
if (logLevel == null) {
addSystemProperty(cmdList, "fess.log.level", null, null);
} else {