From 3919865c65446d1bd3cf0b3a7d74f529d0984b15 Mon Sep 17 00:00:00 2001 From: Shubhankar Ranade Date: Wed, 2 Apr 2025 20:23:36 +0530 Subject: [PATCH 1/2] Upgrade log4j1 to log4j2 --- NOTICE | 6 ++++++ kafka-rest/pom.xml | 15 ++++++++++++-- kafka-rest/src/assembly/package.xml | 4 ++-- licenses/NOTICE.confluent-common.txt | 6 ++++++ licenses/NOTICE.confluent-schema-registry.txt | 6 ++++++ licenses/NOTICE.log4j2.txt | 20 +++++++++++++++++++ 6 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 licenses/NOTICE.log4j2.txt diff --git a/NOTICE b/NOTICE index 3272f57829..16dd1ec732 100644 --- a/NOTICE +++ b/NOTICE @@ -24,6 +24,12 @@ The following libraries are included in packaged versions of this project: * NOTICE: licenses/NOTICE.log4j.txt * HOMEPAGE: http://logging.apache.org/log4j/1.2/ +* Apache Log4j + * COPYRIGHT: Copyright 1999-2024 Apache Software Foundation + * LICENSE: licenses/LICENSE.apache2.txt + * NOTICE: licenses/NOTICE.log4j2.txt + * HOMEPAGE: https://logging.apache.org/log4j/2.x/ + * Apache ZooKeeper * COPYRIGHT: Copyright 2009-2014 The Apache Software Foundation * LICENSE: licenses/LICENSE.apache2.txt diff --git a/kafka-rest/pom.xml b/kafka-rest/pom.xml index baa53211e4..8456c853bb 100644 --- a/kafka-rest/pom.xml +++ b/kafka-rest/pom.xml @@ -63,8 +63,13 @@ ${io.confluent.schema-registry.version} - org.slf4j - slf4j-reload4j + org.apache.logging.log4j + log4j-slf4j-impl + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + runtime io.confluent @@ -147,6 +152,12 @@ kafka-schema-registry ${io.confluent.schema-registry.version} test + + + org.slf4j + slf4j-reload4j + + org.easymock diff --git a/kafka-rest/src/assembly/package.xml b/kafka-rest/src/assembly/package.xml index 1a61dd2bf2..768a34db46 100644 --- a/kafka-rest/src/assembly/package.xml +++ b/kafka-rest/src/assembly/package.xml @@ -47,7 +47,7 @@ io.confluent:rest-utils org.slf4j:slf4j-log4j12 - org.slf4j:slf4j-reload4j + org.apache.logging.log4j:log4j-slf4j-impl @@ -55,7 +55,7 @@ false true - org.slf4j:slf4j-reload4j + org.apache.logging.log4j:log4j-slf4j-impl diff --git a/licenses/NOTICE.confluent-common.txt b/licenses/NOTICE.confluent-common.txt index b92ef9032d..8ec0261f03 100644 --- a/licenses/NOTICE.confluent-common.txt +++ b/licenses/NOTICE.confluent-common.txt @@ -6,6 +6,12 @@ The following libraries are included in packaged versions of this project: * NOTICE: licenses/NOTICE.log4j.txt * HOMEPAGE: http://logging.apache.org/log4j/1.2/ +* Apache Log4j + * COPYRIGHT: Copyright 1999-2024 Apache Software Foundation + * LICENSE: licenses/LICENSE.apache2.txt + * NOTICE: licenses/NOTICE.log4j2.txt + * HOMEPAGE: https://logging.apache.org/log4j/2.x/ + * Apache ZooKeeper * COPYRIGHT: Copyright 2009-2014 The Apache Software Foundation * LICENSE: licenses/LICENSE.apache2.txt diff --git a/licenses/NOTICE.confluent-schema-registry.txt b/licenses/NOTICE.confluent-schema-registry.txt index c4b34db389..95277c0d54 100644 --- a/licenses/NOTICE.confluent-schema-registry.txt +++ b/licenses/NOTICE.confluent-schema-registry.txt @@ -24,6 +24,12 @@ The following libraries are included in packaged versions of this project: * NOTICE: licenses/NOTICE.log4j.txt * HOMEPAGE: http://logging.apache.org/log4j/1.2/ +* Apache Log4j + * COPYRIGHT: Copyright 1999-2024 Apache Software Foundation + * LICENSE: licenses/LICENSE.apache2.txt + * NOTICE: licenses/NOTICE.log4j2.txt + * HOMEPAGE: https://logging.apache.org/log4j/2.x/ + * Apache ZooKeeper * COPYRIGHT: Copyright 2009-2014 The Apache Software Foundation * LICENSE: licenses/LICENSE.apache2.txt diff --git a/licenses/NOTICE.log4j2.txt b/licenses/NOTICE.log4j2.txt new file mode 100644 index 0000000000..0c37b52bfe --- /dev/null +++ b/licenses/NOTICE.log4j2.txt @@ -0,0 +1,20 @@ +Apache Log4j +Copyright 1999-2024 Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +ResolverUtil.java +Copyright 2005-2006 Tim Fennell + +Dumbster SMTP test server +Copyright 2004 Jason Paul Kitchen + +TypeUtil.java +Copyright 2002-2012 Ramnivas Laddad, Juergen Hoeller, Chris Beams + +picocli (http://picocli.info) +Copyright 2017 Remko Popma + +TimeoutBlockingWaitStrategy.java and parts of Util.java +Copyright 2011 LMAX Ltd. From 65e95460a95f0341b4f07018a3c81bbb488ce818 Mon Sep 17 00:00:00 2001 From: Shubhankar Ranade Date: Thu, 3 Apr 2025 13:25:28 +0530 Subject: [PATCH 2/2] Migrate properties files to yaml --- config/log4j.properties | 12 ------- config/log4j2.yaml | 32 +++++++++++++++++++ .../src/test/resources/log4j.properties | 15 --------- kafka-rest/src/test/resources/log4j2.yaml | 22 +++++++++++++ 4 files changed, 54 insertions(+), 27 deletions(-) delete mode 100644 config/log4j.properties create mode 100644 config/log4j2.yaml delete mode 100644 kafka-rest/src/test/resources/log4j.properties create mode 100644 kafka-rest/src/test/resources/log4j2.yaml diff --git a/config/log4j.properties b/config/log4j.properties deleted file mode 100644 index ff3a93fb2a..0000000000 --- a/config/log4j.properties +++ /dev/null @@ -1,12 +0,0 @@ -log4j.rootLogger=INFO, stdout, file - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n - -log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.maxBackupIndex=10 -log4j.appender.file.maxFileSize=100MB -log4j.appender.file.File=${kafka-rest.log.dir}/kafka-rest.log -log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=[%d] %p %m (%c)%n diff --git a/config/log4j2.yaml b/config/log4j2.yaml new file mode 100644 index 0000000000..82c2e341f4 --- /dev/null +++ b/config/log4j2.yaml @@ -0,0 +1,32 @@ +Configuration: + name: "Log4j2" + Properties: + Property: + # Fallback if the system property is not set + - name: "kafka-rest.logs.dir" + value: "." + Appenders: + RollingFile: + name: "file" + fileName: "${sys:kafka-rest.log.dir}/kafka-rest.log" + filePattern: "/kafka-rest.log.%i" + PatternLayout: + pattern: "[%d] %v1Level %m (%c)%n" + Policies: + SizeBasedTriggeringPolicy: + size: "100MB" + DefaultRolloverStrategy: + max: "10" + # Using the min strategy, the newest log file will have index 1 and the oldest one will have index max. + fileIndex: "min" + Console: + name: "STDOUT" + target: "SYSTEM_OUT" + PatternLayout: + pattern: "[%d] %v1Level %m (%c:%L)%n" + Loggers: + Root: + level: "INFO" + AppenderRef: + - ref: "file" + - ref: "STDOUT" diff --git a/kafka-rest/src/test/resources/log4j.properties b/kafka-rest/src/test/resources/log4j.properties deleted file mode 100644 index 613a431401..0000000000 --- a/kafka-rest/src/test/resources/log4j.properties +++ /dev/null @@ -1,15 +0,0 @@ -log4j.rootLogger=TRACE, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%d] %p %m (%c:%L)%n - -log4j.logger.kafka=ERROR -log4j.logger.org.apache.kafka=ERROR - -# zkclient can be verbose, during debugging it is common to adjust is separately -log4j.logger.org.I0Itec.zkclient=ERROR -log4j.logger.org.apache.zookeeper=ERROR - -log4j.logger.org.eclipse=ERROR -log4j.logger.org.hibernate.validator=ERROR \ No newline at end of file diff --git a/kafka-rest/src/test/resources/log4j2.yaml b/kafka-rest/src/test/resources/log4j2.yaml new file mode 100644 index 0000000000..4fc0df1b18 --- /dev/null +++ b/kafka-rest/src/test/resources/log4j2.yaml @@ -0,0 +1,22 @@ +Configuration: + name: "Log4j2" + Appenders: + Console: + name: "STDOUT" + target: "SYSTEM_OUT" + PatternLayout: + pattern: "[%d] %v1Level %m (%c:%L)%n" + Loggers: + Root: + level: "TRACE" + AppenderRef: + ref: "STDOUT" + Logger: + - name: "kafka" + level: "ERROR" + - name: "org.apache.kafka" + level: "ERROR" + - name: "org.eclipse" + level: "ERROR" + - name: "org.hibernate.validator" + level: "ERROR"