add logging.properties
This commit is contained in:
parent
1dad93d63f
commit
f845f1f353
5 changed files with 66 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
FESS_CLASSPATH=$FESS_HOME/lib
|
||||
FESS_CLASSPATH=$FESS_HOME/lib/classes
|
||||
|
||||
if [ "x$FESS_MIN_MEM" = "x" ]; then
|
||||
FESS_MIN_MEM=256m
|
||||
|
@ -70,6 +70,7 @@ 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.home=$FESS_HOME"
|
||||
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"
|
10
src/main/assemblies/files/logging.properties
Normal file
10
src/main/assemblies/files/logging.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
handlers=java.util.logging.FileHandler
|
||||
.level=INFO
|
||||
|
||||
java.util.logging.ConsoleHandler.level=INFO
|
||||
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||
|
||||
java.util.logging.FileHandler.level=INFO
|
||||
java.util.logging.FileHandler.pattern=${fess.home}/logs/server_%g.log
|
||||
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
|
||||
java.util.logging.FileHandler.count=10
|
|
@ -22,18 +22,25 @@
|
|||
<!-- lib -->
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/tomcat-lib</directory>
|
||||
<outputDirectory>fess-${project.version}/lib</outputDirectory>
|
||||
<outputDirectory>fess-${project.version}/lib/classes</outputDirectory>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/fess/WEB-INF/classes/org/codelibs/fess/</directory>
|
||||
<includes>
|
||||
<include>FessBoot**</include>
|
||||
</includes>
|
||||
<outputDirectory>fess-${project.version}/lib/org/codelibs/fess</outputDirectory>
|
||||
<outputDirectory>fess-${project.version}/lib/classes/org/codelibs/fess</outputDirectory>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/assemblies/files</directory>
|
||||
<includes>
|
||||
<include>logging.properties</include>
|
||||
</includes>
|
||||
<outputDirectory>fess-${project.version}/lib/classes</outputDirectory>
|
||||
</fileSet>
|
||||
<!-- app -->
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/assemblies/scripts</directory>
|
||||
<directory>${project.basedir}/src/main/assemblies/files</directory>
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>lf</lineEnding>
|
||||
<includes>
|
||||
|
@ -44,7 +51,7 @@
|
|||
</fileSet>
|
||||
<!-- logs -->
|
||||
<fileSet>
|
||||
<directory>src/main/assemblies/scripts</directory>
|
||||
<directory>src/main/assemblies/files</directory>
|
||||
<outputDirectory>fess-${project.version}/logs</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>*</exclude>
|
||||
|
@ -53,7 +60,7 @@
|
|||
</fileSet>
|
||||
<!-- temp -->
|
||||
<fileSet>
|
||||
<directory>src/main/assemblies/scripts</directory>
|
||||
<directory>src/main/assemblies/files</directory>
|
||||
<outputDirectory>fess-${project.version}/temp</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>*</exclude>
|
||||
|
@ -67,7 +74,7 @@
|
|||
</fileSet>
|
||||
<!-- es/data -->
|
||||
<fileSet>
|
||||
<directory>src/main/assemblies/scripts</directory>
|
||||
<directory>src/main/assemblies/files</directory>
|
||||
<outputDirectory>fess-${project.version}/es/data</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>*</exclude>
|
||||
|
|
|
@ -1,11 +1,24 @@
|
|||
package org.codelibs.fess;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.dbflute.tomcat.TomcatBoot;
|
||||
|
||||
public class FessBoot extends TomcatBoot {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(FessBoot.class.getPackage().getName());
|
||||
|
||||
private static final String LOGGING_PROPERTIES = "/logging.properties";
|
||||
|
||||
private static final String FESS_CONTEXT_PATH = "fess.context.path";
|
||||
|
||||
private static final String FESS_PORT = "fess.port";
|
||||
|
@ -18,6 +31,10 @@ public class FessBoot extends TomcatBoot {
|
|||
|
||||
private static final String JAVA_IO_TMPDIR = "java.io.tmpdir";
|
||||
|
||||
private static final int DEFAULT_BUF_SIZE = 4096;
|
||||
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
public FessBoot(int port, String contextPath) {
|
||||
super(port, contextPath);
|
||||
}
|
||||
|
@ -52,7 +69,7 @@ public class FessBoot extends TomcatBoot {
|
|||
|
||||
@Override
|
||||
protected void info(String msg) {
|
||||
// TODO
|
||||
logger.info(msg);
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -60,6 +77,29 @@ public class FessBoot extends TomcatBoot {
|
|||
// ============
|
||||
|
||||
public static void main(String[] args) {
|
||||
try (InputStream is = FessBoot.class.getResourceAsStream(LOGGING_PROPERTIES)) {
|
||||
if (is != null) {
|
||||
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
|
||||
final ByteBuffer buffer = ByteBuffer.allocate(DEFAULT_BUF_SIZE);
|
||||
final byte[] buf = buffer.array();
|
||||
int len;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
|
||||
String configContent = out.toString(UTF_8);
|
||||
final String fessHomeDir = System.getProperty("fess.home");
|
||||
if (fessHomeDir != null) {
|
||||
configContent = configContent.replaceAll(Pattern.quote("${fess.home}"), fessHomeDir);
|
||||
}
|
||||
|
||||
LogManager.getLogManager().readConfiguration(new ByteArrayInputStream(configContent.getBytes(UTF_8)));
|
||||
logger.info(LOGGING_PROPERTIES + " is loaded.");
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARNING, "Failed to load " + LOGGING_PROPERTIES, e);
|
||||
}
|
||||
new FessBoot(getPort(), getContextPath()).useTldDetect().asDevelopment(isNoneEnv()).bootAwait();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue