modify log handling
This commit is contained in:
parent
3b933aa310
commit
6ad359844a
7 changed files with 138 additions and 64 deletions
5
pom.xml
5
pom.xml
|
@ -383,6 +383,11 @@
|
|||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.janino</groupId>
|
||||
<artifactId>janino</artifactId>
|
||||
<version>2.7.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
|
|
|
@ -67,10 +67,16 @@ JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC"
|
|||
# Ensure UTF-8 encoding by default (e.g. filenames)
|
||||
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
|
||||
|
||||
# Application Configuration
|
||||
APP_NAME=fess
|
||||
ES_HOME=$FESS_HOME/es
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.context.path=/fess"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.context.path=/$APP_NAME"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.port=8080"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.webapp.path=$FESS_HOME/app"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.webxml.path=$FESS_HOME/app/WEB-INF/web.xml"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.temp.path=$FESS_HOME/temp"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.name=$APP_NAME"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.path=$FESS_HOME/logs"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dfess.log.level=info"
|
||||
FESS_JAVA_OPTS="$FESS_JAVA_OPTS -Dlasta.env=production"
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public class FessBoot extends TomcatBoot {
|
|||
return super.prepareWebXmlPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMarkDir() {
|
||||
String value = System.getProperty(FESS_TEMP_PATH);
|
||||
if (value != null) {
|
||||
|
@ -49,6 +50,11 @@ public class FessBoot extends TomcatBoot {
|
|||
return new File(System.getProperty(JAVA_IO_TMPDIR), "fessboot").getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void info(String msg) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// main
|
||||
// ============
|
||||
|
|
|
@ -236,7 +236,7 @@ public class FessEsClient implements Client {
|
|||
if (transportAddressList.isEmpty()) {
|
||||
if (runner == null) {
|
||||
runner = new ElasticsearchClusterRunner();
|
||||
final Configs config = newConfigs().clusterName(clusterName).numOfNode(1);
|
||||
final Configs config = newConfigs().clusterName(clusterName).numOfNode(1).useLogger();
|
||||
final String esDir = System.getProperty("fess.es.dir");
|
||||
if (esDir != null) {
|
||||
config.basePath(esDir);
|
||||
|
|
|
@ -57,12 +57,11 @@ public class SystemHelper implements Serializable {
|
|||
|
||||
private final Set<String> adminRoleSet = new HashSet<>();
|
||||
|
||||
private String[] crawlerJavaOptions = new String[] { "-Djava.awt.headless=true", "-server", "-Xmx512m", "-XX:MaxPermSize=128m",
|
||||
"-XX:-UseGCOverheadLimit", "-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-XX:+CMSIncrementalMode",
|
||||
"-XX:+CMSIncrementalPacing", "-XX:CMSIncrementalDutyCycleMin=0", "-XX:+UseParNewGC", "-XX:+UseStringCache", "-XX:+UseTLAB",
|
||||
"-XX:+DisableExplicitGC" };
|
||||
private String[] crawlerJavaOptions = new String[] { "-Djava.awt.headless=true", "-server", "-Xmx256m", "-XX:MaxMetaspaceSize=128m",
|
||||
"-XX:CompressedClassSpaceSize=32m", "-XX:-UseGCOverheadLimit", "-XX:+UseConcMarkSweepGC",
|
||||
"-XX:CMSInitiatingOccupancyFraction=75", "-XX:+UseParNewGC", "-XX:+UseTLAB", "-XX:+DisableExplicitGC" };
|
||||
|
||||
private String logFilePath = System.getProperty("fess.log.file");
|
||||
private String logFilePath = System.getProperty("fess.log.path", "target/logs");
|
||||
|
||||
private String javaCommandPath = "java";
|
||||
|
||||
|
|
|
@ -241,7 +241,8 @@ public class CrawlJob {
|
|||
buf.append("classes");
|
||||
// target/classes
|
||||
final String userDir = System.getProperty("user.dir");
|
||||
final File targetClassesDir = new File(userDir, "target" + File.separator + "classes");
|
||||
final File targetDir = new File(userDir, "target");
|
||||
final File targetClassesDir = new File(targetDir, "classes");
|
||||
if (targetClassesDir.isDirectory()) {
|
||||
buf.append(cpSeparator);
|
||||
buf.append(targetClassesDir.getAbsolutePath());
|
||||
|
@ -251,8 +252,7 @@ public class CrawlJob {
|
|||
// WEB-INF/cmd/lib
|
||||
appendJarFile(cpSeparator, buf, new File(servletContext.getRealPath("/WEB-INF/cmd/lib")), "WEB-INF/cmd" + File.separator + "lib"
|
||||
+ File.separator);
|
||||
final File targetLibDir =
|
||||
new File(userDir, "target" + File.separator + "fess" + File.separator + "WEB-INF" + File.separator + "lib");
|
||||
final File targetLibDir = new File(targetDir, "fess" + File.separator + "WEB-INF" + File.separator + "lib");
|
||||
if (targetLibDir.isDirectory()) {
|
||||
appendJarFile(cpSeparator, buf, targetLibDir, targetLibDir.getAbsolutePath() + File.separator);
|
||||
}
|
||||
|
@ -271,9 +271,13 @@ public class CrawlJob {
|
|||
|
||||
crawlerCmdList.add("-Dfess.crawler.process=true");
|
||||
if (logFilePath == null) {
|
||||
logFilePath = systemHelper.getLogFilePath();
|
||||
final String value = System.getProperty("fess.log.path");
|
||||
logFilePath = value != null ? value : new File(targetDir, "logs").getAbsolutePath();
|
||||
}
|
||||
crawlerCmdList.add("-Dfess.log.file=" + logFilePath);
|
||||
crawlerCmdList.add("-Dfess.log.path=" + logFilePath);
|
||||
addSystemProperty(crawlerCmdList, "lasta.env", null, null);
|
||||
addSystemProperty(crawlerCmdList, "fess.log.name", "fess-crawler", "-crawler");
|
||||
addSystemProperty(crawlerCmdList, "fess.log.level", null, null);
|
||||
if (systemHelper.getCrawlerJavaOptions() != null) {
|
||||
for (final String value : systemHelper.getCrawlerJavaOptions()) {
|
||||
crawlerCmdList.add(value);
|
||||
|
@ -364,6 +368,20 @@ public class CrawlJob {
|
|||
}
|
||||
}
|
||||
|
||||
private void addSystemProperty(final List<String> crawlerCmdList, final String name, final String defaultValue, final String appendValue) {
|
||||
final String value = System.getProperty(name);
|
||||
if (value != null) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("-D").append(name).append("=").append(value);
|
||||
if (appendValue != null) {
|
||||
buf.append(appendValue);
|
||||
}
|
||||
crawlerCmdList.add(buf.toString());
|
||||
} else if (defaultValue != null) {
|
||||
crawlerCmdList.add("-D" + name + "=" + defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteTempDir(final File ownTmpDir) {
|
||||
if (ownTmpDir == null) {
|
||||
return;
|
||||
|
|
|
@ -1,57 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ -->
|
||||
<!-- Harbor logging settings for Local Development -->
|
||||
<!-- _/_/_/_/_/_/_/_/_/_/ -->
|
||||
<configuration>
|
||||
<property name="domain.name" value="fess"/>
|
||||
<property name="log.level" value="debug"/>
|
||||
<property name="log.pattern" value="%d [%t] %-5p \\(%C{0}@%M\\(\\):%L\\) - %m%n"/>
|
||||
<property name="log.file.basedir" value="/tmp/lastaflute/fess"/>
|
||||
<property name="backup.date.suffix" value="_%d{yyyyMMdd}"/>
|
||||
<property name="backup.max.history" value="180"/>
|
||||
<property name="domain.name" value="${fess.log.name:-fess}" />
|
||||
<property name="log.level" value="${fess.log.level:-debug}" />
|
||||
<property name="log.pattern" value="%d [%t] %-5p %msg%n" />
|
||||
<!-- <property name="log.pattern" value="%d [%t] %-5p \\(%C{0}@%M\\(\\):%L\\) - %msg%n" /> -->
|
||||
<property name="log.file.basedir" value="${fess.log.path:-target/logs}" />
|
||||
<property name="backup.date.suffix" value="_%d{yyyyMMdd}" />
|
||||
<property name="backup.max.history" value="180" />
|
||||
<property name="audit.log.pattern" value="%d %msg%n" />
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder><pattern>${log.pattern}</pattern></encoder>
|
||||
</appender>
|
||||
<appender name="appfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/app_${domain.name}.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder><pattern>${log.pattern}</pattern></encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/app_${domain.name}${backup.date.suffix}.log</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="errorfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/error_${domain.name}.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder><pattern>${log.pattern}</pattern></encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"><level>ERROR</level></filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/error_${domain.name}${backup.date.suffix}.log</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="mailfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/mail_${domain.name}.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder><pattern>${log.pattern}</pattern></encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/mail_${domain.name}${backup.date.suffix}.log</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="appfile"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/${domain.name}.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/${domain.name}${backup.date.suffix}.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="auditfile"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/audit.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder>
|
||||
<pattern>${audit.log.pattern}</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/audit${backup.date.suffix}.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
<appender name="mailfile"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${log.file.basedir}/mail.log</File>
|
||||
<Append>true</Append>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<fileNamePattern>${log.file.basedir}/backup/mail${backup.date.suffix}.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>${backup.max.history}</maxHistory>
|
||||
</rollingPolicy>
|
||||
</appender>
|
||||
|
||||
<logger name="org.codelibs.fess" additivity="false" level="${log.level}">
|
||||
<appender-ref ref="console"/><appender-ref ref="appfile"/><appender-ref ref="errorfile"/>
|
||||
</logger>
|
||||
<logger name="org.dbflute" additivity="false" level="${log.level}">
|
||||
<appender-ref ref="console"/><appender-ref ref="appfile"/><appender-ref ref="errorfile"/>
|
||||
</logger>
|
||||
<logger name="org.lastaflute" additivity="false" level="${log.level}">
|
||||
<appender-ref ref="console"/><appender-ref ref="appfile"/><appender-ref ref="errorfile"/>
|
||||
</logger>
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/><appender-ref ref="errorfile"/>
|
||||
</root>
|
||||
<logger name="org.codelibs.fess" additivity="false" level="${log.level}">
|
||||
<if condition='isNull("lasta.env")'>
|
||||
<then>
|
||||
<appender-ref ref="console" />
|
||||
</then>
|
||||
</if>
|
||||
<appender-ref ref="appfile" />
|
||||
</logger>
|
||||
<logger name="org.dbflute" additivity="false" level="${log.level}">
|
||||
<if condition='isNull("lasta.env")'>
|
||||
<then>
|
||||
<appender-ref ref="console" />
|
||||
</then>
|
||||
</if>
|
||||
<appender-ref ref="appfile" />
|
||||
</logger>
|
||||
<logger name="org.lastaflute" additivity="false" level="${log.level}">
|
||||
<if condition='isNull("lasta.env")'>
|
||||
<then>
|
||||
<appender-ref ref="console" />
|
||||
</then>
|
||||
</if>
|
||||
<appender-ref ref="appfile" />
|
||||
</logger>
|
||||
<logger name="fess.log.audit" additivity="false" level="info">
|
||||
<if condition='isNull("lasta.env")'>
|
||||
<then>
|
||||
<appender-ref ref="console" />
|
||||
</then>
|
||||
</if>
|
||||
<appender-ref ref="auditfile" />
|
||||
</logger>
|
||||
<root level="info">
|
||||
<if condition='isNull("lasta.env")'>
|
||||
<then>
|
||||
<appender-ref ref="console" />
|
||||
</then>
|
||||
</if>
|
||||
<appender-ref ref="appfile" />
|
||||
</root>
|
||||
</configuration>
|
||||
|
|
Loading…
Add table
Reference in a new issue