mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-09-15 02:17:57 +00:00
Add customized log file with 7 day retention (#455)
This commit is contained in:
@@ -60,6 +60,7 @@ COPY mcstatus /usr/local/bin
|
|||||||
|
|
||||||
VOLUME ["/data","/mods","/config"]
|
VOLUME ["/data","/mods","/config"]
|
||||||
COPY server.properties /tmp/server.properties
|
COPY server.properties /tmp/server.properties
|
||||||
|
COPY log4j2.xml /tmp/log4j2.xml
|
||||||
WORKDIR /data
|
WORKDIR /data
|
||||||
|
|
||||||
ENTRYPOINT [ "/start" ]
|
ENTRYPOINT [ "/start" ]
|
||||||
|
|||||||
+34
@@ -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
|
||||||
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)
|
# Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades)
|
||||||
log "Checking for JSON files."
|
log "Checking for JSON files."
|
||||||
JSON_FILES=$(find . -maxdepth 1 -name '*.json')
|
JSON_FILES=$(find . -maxdepth 1 -name '*.json')
|
||||||
|
|||||||
Reference in New Issue
Block a user