Skip to content

Commit f8ff8a7

Browse files
authored
Opt into generated log4j2.xml configuration (#3856)
1 parent 9c01462 commit f8ff8a7

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ jobs:
175175
MINECRAFT_VERSION: ${{ matrix.mcVersion }}
176176
VARIANT: ${{ matrix.variant }}
177177
CF_API_KEY: ${{ secrets.CF_API_KEY }}
178+
GH_TOKEN: ${{ github.token }}
178179
run: |
179180
tests/test.sh
180181

.github/workflows/verify-pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,6 @@ jobs:
9292
VARIANT: ${{ matrix.variant }}
9393
CF_API_KEY: ${{ secrets.CF_API_KEY }}
9494
DEBUG: ${{ runner.debug }}
95+
GH_TOKEN: ${{ github.token }}
9596
run: |
9697
tests/test.sh

docs/configuration/misc-options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ The openj9 image tags include specific variables to simplify configuration:
8181

8282
The image now uses a templated log4j2 configuration based on PaperMC's logging setup, which is automatically applied for versions that don't require Log4j security patches. This configuration provides rolling logs and advanced logging features by default.
8383

84+
Set the environment variable `GENERATE_LOG4J2_CONFIG` to "true" to enable the following features.
85+
8486
### Customization via environment variables
8587

8688
You can customize various aspects of the logging behavior using environment variables:

scripts/start-finalExec

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if [ -n "$ICON" ]; then
4747
fi
4848
fi
4949

50-
canUseRollingLogs=true
50+
useGeneratedLogs=${GENERATE_LOG4J2_CONFIG:-false}
5151
useFallbackJvmFlag=false
5252

5353
SERVER_DIR="$baseDataDir"
@@ -65,7 +65,7 @@ patchLog4jConfig() {
6565
return 1
6666
fi
6767
JVM_OPTS="-Dlog4j.configurationFile=${file} ${JVM_OPTS}"
68-
canUseRollingLogs=false
68+
useGeneratedLogs=false
6969
}
7070

7171
# Temporarily disable debugging output
@@ -104,7 +104,8 @@ elif versionLessThan 1.18.1; then
104104
fi
105105

106106
# Set up log4j2 configuration with templating support
107-
if ${canUseRollingLogs}; then
107+
LOGFILE="${SERVER_DIR}/log4j2.xml"
108+
if ${useGeneratedLogs}; then
108109
# Set up log configuration defaults
109110
: "${LOG_LEVEL:=info}"
110111
: "${ROLLING_LOG_MAX_FILES:=1000}"
@@ -128,7 +129,6 @@ if ${canUseRollingLogs}; then
128129
export LOG_LEVEL ROLLING_LOG_FILE_PATTERN ROLLING_LOG_MAX_FILES
129130
export LOG_CONSOLE_FORMAT LOG_TERMINAL_FORMAT LOG_FILE_FORMAT
130131

131-
LOGFILE="${SERVER_DIR}/log4j2.xml"
132132

133133
# Always regenerate if file doesn't exist
134134
if [ ! -e "$LOGFILE" ] || isTrue "${REGENERATE_LOG4J2:-true}"; then
@@ -176,6 +176,8 @@ elif isTrue "${ENABLE_ROLLING_LOGS:-false}"; then
176176
# Legacy behavior: error if rolling logs explicitly requested but not possible
177177
logError "Using rolling logs is currently not possible in the selected version due to CVE-2021-44228"
178178
exit 1
179+
else
180+
rm -f "${LOGFILE}"
179181
fi
180182

181183
# Optional disable console

0 commit comments

Comments
 (0)