Skip to content

Commit 5ae4b62

Browse files
authored
KAFKA-18347 Add tools-log4j2.yaml to config and remove unsed tools-log4j.properties from config (apache#18351)
Reviewers: Chia-Ping Tsai <[email protected]>
1 parent ce5bd19 commit 5ae4b62

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

bin/kafka-run-class.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fi
2323
# WINDOWS_OS_FORMAT == 1 if Cygwin or MinGW is detected, else 0.
2424
if [[ $(uname -a) =~ "CYGWIN" || $(uname -a) =~ "MINGW" || $(uname -a) =~ "MSYS" ]]; then
2525
WINDOWS_OS_FORMAT=1
26-
export MSYS2_ARG_CONV_EXCL="-Xlog:gc*:file=;-Dlog4j.configuration=;$MSYS2_ARG_CONV_EXCL"
26+
export MSYS2_ARG_CONV_EXCL="-Xlog:gc*:file=;-Dlog4j2.configurationFile=;$MSYS2_ARG_CONV_EXCL"
2727
else
2828
WINDOWS_OS_FORMAT=0
2929
fi
@@ -220,10 +220,10 @@ fi
220220
# Log4j settings
221221
if [ -z "$KAFKA_LOG4J_OPTS" ]; then
222222
# Log to console. This is a tool.
223-
LOG4J_DIR="$base_dir/config/tools-log4j.properties"
223+
LOG4J_DIR="$base_dir/config/tools-log4j2.yaml"
224224
# If Cygwin is detected, LOG4J_DIR is converted to Windows format.
225225
(( WINDOWS_OS_FORMAT )) && LOG4J_DIR=$(cygpath --path --mixed "${LOG4J_DIR}")
226-
KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:${LOG4J_DIR}"
226+
KAFKA_LOG4J_OPTS="-Dlog4j2.configurationFile=${LOG4J_DIR}"
227227
else
228228
if echo "$KAFKA_LOG4J_OPTS" | grep -E "log4j\.[^[:space:]]+(\.properties|\.xml)$"; then
229229
# Enable Log4j 1.x configuration compatibility mode for Log4j 2

bin/windows/kafka-run-class.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ IF ["%LOG_DIR%"] EQU [""] (
116116

117117
rem Log4j settings
118118
IF ["%KAFKA_LOG4J_OPTS%"] EQU [""] (
119-
set KAFKA_LOG4J_OPTS=-Dlog4j.configuration=file:%BASE_DIR%/config/tools-log4j.properties
119+
set KAFKA_LOG4J_OPTS=-Dlog4j2.configurationFile=file:%BASE_DIR%/config/tools-log4j2.yaml
120120
) ELSE (
121121
rem Check if Log4j 1.x configuration options are present in KAFKA_LOG4J_OPTS
122122
echo %KAFKA_LOG4J_OPTS% | findstr /r /c:"log4j\.[^ ]*(\.properties|\.xml)$" >nul

config/tools-log4j.properties renamed to config/tools-log4j2.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,21 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
Configuration:
16+
Properties:
17+
Property:
18+
- name: "logPattern"
19+
value: "[%d] %p %m (%c)%n"
1520

16-
log4j.rootLogger=WARN, stderr
21+
Appenders:
22+
Console:
23+
name: STDERR
24+
target: SYSTEM_ERR
25+
PatternLayout:
26+
pattern: "${logPattern}"
27+
Loggers:
28+
Root:
29+
level: WARN
30+
AppenderRef:
31+
- ref: STDERR
1732

18-
log4j.appender.stderr=org.apache.log4j.ConsoleAppender
19-
log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
20-
log4j.appender.stderr.layout.ConversionPattern=[%d] %p %m (%c)%n
21-
log4j.appender.stderr.Target=System.err

0 commit comments

Comments
 (0)