mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-11-10 14:24:28 +00:00
Add customized log file with 7 day retention (#455)
This commit is contained in:
parent
7702d98766
commit
fc6129261b
3 changed files with 45 additions and 0 deletions
|
@ -60,6 +60,7 @@ COPY mcstatus /usr/local/bin
|
|||
|
||||
VOLUME ["/data","/mods","/config"]
|
||||
COPY server.properties /tmp/server.properties
|
||||
COPY log4j2.xml /tmp/log4j2.xml
|
||||
WORKDIR /data
|
||||
|
||||
ENTRYPOINT [ "/start" ]
|
||||
|
|
34
log4j2.xml
Normal file
34
log4j2.xml
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN" packages="com.mojang.util">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
</Console>
|
||||
<Queue name="ServerGuiConsole">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
|
||||
</Queue>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy>
|
||||
<Delete basePath="logs">
|
||||
<IfFileName glob="*.log.gz" />
|
||||
<IfLastModified age="7d" />
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="ServerGuiConsole"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
|
@ -27,6 +27,16 @@ if [ -n "$ICON" -a ! -e server-icon.png ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Set up log configuration
|
||||
LOGFILE="/data/log4j2.xml"
|
||||
if [ ! -e "$LOGFILE" ]; then
|
||||
log "Creating log4j2.xml in ${LOGFILE}"
|
||||
cp /tmp/log4j2.xml "$LOGFILE"
|
||||
else
|
||||
log "log4j2.xml already created, skipping"
|
||||
fi
|
||||
JVM_OPTS="-Dlog4j.configurationFile=/data/log4j2.xml ${JVM_OPTS}"
|
||||
|
||||
# Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
|
||||
log "Checking for JSON files."
|
||||
JSON_FILES=$(find . -maxdepth 1 -name '*.json')
|
||||
|
|
Loading…
Reference in a new issue