MINOR: log4j2 upgrade follow-up#18290
Conversation
|
@frankvicky as @ijuma's comment in https://issues.apache.org/jira/browse/KAFKA-18247, please add the |
a5214a4 to
3b5a4c6
Compare
| See <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=181308223">KIP-750</a> for more details | ||
| </li> | ||
| <li> | ||
| Logging framework has been migrated from Log4j to Log4j2. |
There was a problem hiding this comment.
Shall we mention the behavior if you do not convert the configuration files? I believe there is a compatibility mode with some limitations?
There was a problem hiding this comment.
Log4j provides a way to convert Log4j 1.x properties at runtime (Log4j Migration Guide).
To enable this feature, we can set both LOG4J_COMPATIBILITY=true and specify the configuration file using LOG4J_CONFIGURATION_FILE=file.
There was a problem hiding this comment.
Do we want to automatically detect if log4j 1.x properties are used and, if so, automatically enable this mode? It seems like a huge problem if customers lose their logging while upgrading to 4.0+.
There was a problem hiding this comment.
We can always enable that compatibility feature as the bridge jar is already included now.
There was a problem hiding this comment.
Even better if it can be always enabled with no significant downside.
chia7712
left a comment
There was a problem hiding this comment.
@frankvicky thanks for your patch
| implementation project(':storage') | ||
| implementation project(':server-common') | ||
| implementation libs.slf4jApi | ||
| implementation libs.jacksonDatabindYaml |
There was a problem hiding this comment.
this is required as test-common needs to parse yaml in production code.
| @@ -1588,7 +1588,6 @@ project(':test-common') { | |||
| implementation project(':storage') | |||
| implementation project(':server-common') | |||
| implementation libs.slf4jApi | |||
There was a problem hiding this comment.
Could you please take a look at @ijuma's comment (#17373 (comment))
maybe we can create a variable to collect them and then add them to implementation for each module:
log4jRuntimeLibs = [
libs.log4j1Bridge2Api
libs.jacksonDatabindYaml
]
log4jLibs = [
libs.slf4jApi
libs.slf4jLog4j2
libs.log4j2Api
libs.log4j2Core
]
...
implementation log4jLibs
runtimeOnly log4jRuntimeLibs
There was a problem hiding this comment.
I have tried it on my local machine but it led to tons of failure of tests.
I would keep debugging on my local machine.
| See <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=181308223">KIP-750</a> for more details | ||
| </li> | ||
| <li> | ||
| Logging framework has been migrated from Log4j to Log4j2. |
There was a problem hiding this comment.
Log4j provides a way to convert Log4j 1.x properties at runtime (Log4j Migration Guide).
To enable this feature, we can set both LOG4J_COMPATIBILITY=true and specify the configuration file using LOG4J_CONFIGURATION_FILE=file.
c95cd3c to
c69d421
Compare
| implementation libs.slf4jApi | ||
| implementation libs.opentelemetryProto | ||
| implementation libs.protobuf | ||
| implementation log4jLibs |
There was a problem hiding this comment.
Hmm, clients and streams should not have any log dependency besides slf4j. The idea is that client modules shouldn't include logging implementations while server modules should. Client modules run alongside user applications and the logging library should be aligned with the application logging library.
chia7712
left a comment
There was a problem hiding this comment.
@frankvicky could you please also remove log4j2CoreTest? it is unused.
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| Configuration: |
There was a problem hiding this comment.
Could you please open a jira for this change? tools-log4j.properties is still used in code base
There was a problem hiding this comment.
| implementation libs.junitPlatformLanucher | ||
| implementation libs.junitJupiterApi | ||
| implementation libs.junitJupiter | ||
| implementation log4jLibs |
There was a problem hiding this comment.
line#1656 implementation libs.slf4jApi is unnecessary now.
e6000ec to
5af4fb4
Compare
| LOG4J1_CONFIG=$(echo "$KAFKA_LOG4J_OPTS" | grep -o 'log4j\.configuration=\S*' | cut -d'=' -f2) | ||
|
|
||
| # Enable Log4j 1.x configuration compatibility mode for Log4j 2 | ||
| export LOG4J_COMPATIBILITY=true |
There was a problem hiding this comment.
@frankvicky could you please test the compatibility on your local?
There was a problem hiding this comment.
From document, set one of confituration from log4j1.compatibility and log4j.configuration if needing to install log4j1 to log4j2 bridge. It looks like we can set LOG4J_COMPATIBILITY=true only if LOG4J1_CONFIG has properties file. Also, setting LOG4J_CONFIGURATION_FILE="$LOG4J1_CONFIG" only if LOG4J1_CONFIG doesn't have properties file.
https://logging.apache.org/log4j/2.x/migrate-from-log4j1.html#ConfigurationCompatibility
5af4fb4 to
279ede0
Compare
|
Hi @chia7712 |
FrankYang0529
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the patch. With log4j 1 properties, I can see log on console.
| // ZooKeeper (potentially older and containing CVEs) | ||
| libs.nettyHandler, | ||
| libs.nettyTransportNativeEpoll, | ||
| libs.slf4jApi, |
There was a problem hiding this comment.
spotbugsSlf4j - configuration for the SLF4J provider to run SpotBugs
\--- org.slf4j:slf4j-simple:2.0.0
\--- org.slf4j:slf4j-api:2.0.0
spotbugs requires the 2.x slf4j, so forcing the version can cause log issue in running spotbugs
There was a problem hiding this comment.
I previously encountered version inconsistency issues on my local machine. While those issues have been resolved, this change represents a modification that should have been removed but was accidentally missed during cleanup. 😬
279ede0 to
14fb9ed
Compare
Reviewers: PoAn Yang <payang@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
Reviewers: PoAn Yang <payang@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>


Please refer to #17373 (comment) for further details.
This PR does the following things:
kafka-run-classCommitter Checklist (excluded from commit message)