You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "frankvicky (via GitHub)" <gi...@apache.org> on 2025/02/19 16:48:46 UTC
[PR] [WIP]KAFKA-18331: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
frankvicky opened a new pull request, #18969:
URL: https://github.com/apache/kafka/pull/18969
JIRA: KAFKA-18331
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18831: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #18969:
URL: https://github.com/apache/kafka/pull/18969
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [WIP]KAFKA-18331: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #18969:
URL: https://github.com/apache/kafka/pull/18969#discussion_r1962907658
##########
core/src/main/scala/kafka/utils/LoggingController.scala:
##########
@@ -112,24 +112,30 @@ private class Log4jCoreController extends LoggingControllerDelegate {
val level = Level.toLevel(logLevel.toUpperCase(Locale.ROOT))
if (loggerName == ROOT_LOGGER) {
- Configurator.setAllLevels(LogManager.ROOT_LOGGER_NAME, level)
+ Configurator.setLevel(LogManager.ROOT_LOGGER_NAME, level)
true
} else {
if (loggerExists(loggerName) && level != null) {
- Configurator.setAllLevels(loggerName, level)
+ Configurator.setLevel(loggerName, level)
true
}
else false
}
}
override def unsetLogLevel(loggerName: String): Boolean = {
+ val nullLevel: String = null
if (loggerName == ROOT_LOGGER) {
- Configurator.setAllLevels(LogManager.ROOT_LOGGER_NAME, null)
+ Configurator.setLevel(LogManager.ROOT_LOGGER_NAME, nullLevel)
true
} else {
if (loggerExists(loggerName)) {
- Configurator.setAllLevels(loggerName, null)
+ val parent = logContext.getLogger(loggerName).getParent
+ if (parent == null) {
+ Configurator.setLevel(loggerName, nullLevel)
+ } else {
+ Configurator.setLevel(loggerName, parent.getLevel)
+ }
Review Comment:
I try to align with the behavior of the old version of Kafka here.
https://github.com/apache/kafka/blob/66e2ac0e098f6ee83deaf5501bf3f606d29b35fa/core/src/main/scala/kafka/utils/Log4jController.scala#L33-L49
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18831: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #18969:
URL: https://github.com/apache/kafka/pull/18969#issuecomment-2673864688
For future reference: Changing logger levels distinguishes between connector and admin APIs. The connector API uses "namespace"-based logger level changes, while the admin API uses specific logger-based changes. Therefore, this PR uses `setLevel` for the core module and `setAllLevels` for the connect module.
I have test the PR locally - see following screenshot
### case 0: changing root level does not impact other loggers

### case 1: the loggers defined by configs are not impacted by parent logger

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18831: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18969:
URL: https://github.com/apache/kafka/pull/18969#discussion_r1963548344
##########
core/src/main/scala/kafka/utils/LoggingController.scala:
##########
@@ -112,24 +112,30 @@ private class Log4jCoreController extends LoggingControllerDelegate {
val level = Level.toLevel(logLevel.toUpperCase(Locale.ROOT))
if (loggerName == ROOT_LOGGER) {
- Configurator.setAllLevels(LogManager.ROOT_LOGGER_NAME, level)
+ Configurator.setLevel(LogManager.ROOT_LOGGER_NAME, level)
true
} else {
if (loggerExists(loggerName) && level != null) {
- Configurator.setAllLevels(loggerName, level)
+ Configurator.setLevel(loggerName, level)
true
}
else false
}
}
override def unsetLogLevel(loggerName: String): Boolean = {
+ val nullLevel: String = null
Review Comment:
we can't use null string, as it is converted to DEBUG level by default.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18831: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #18969:
URL: https://github.com/apache/kafka/pull/18969#discussion_r1963550245
##########
core/src/main/scala/kafka/utils/LoggingController.scala:
##########
@@ -112,24 +112,30 @@ private class Log4jCoreController extends LoggingControllerDelegate {
val level = Level.toLevel(logLevel.toUpperCase(Locale.ROOT))
if (loggerName == ROOT_LOGGER) {
- Configurator.setAllLevels(LogManager.ROOT_LOGGER_NAME, level)
+ Configurator.setLevel(LogManager.ROOT_LOGGER_NAME, level)
true
} else {
if (loggerExists(loggerName) && level != null) {
- Configurator.setAllLevels(loggerName, level)
+ Configurator.setLevel(loggerName, level)
true
}
else false
}
}
override def unsetLogLevel(loggerName: String): Boolean = {
+ val nullLevel: String = null
Review Comment:
could you please try to set null "level" instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18831: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #18969:
URL: https://github.com/apache/kafka/pull/18969#issuecomment-2673874056
cherry-pick to 4.0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18831: Migrating to log4j2 introduce behavior changes of adjusting level dynamically [kafka]
Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #18969:
URL: https://github.com/apache/kafka/pull/18969#discussion_r1963591806
##########
core/src/main/scala/kafka/utils/LoggingController.scala:
##########
@@ -112,24 +112,30 @@ private class Log4jCoreController extends LoggingControllerDelegate {
val level = Level.toLevel(logLevel.toUpperCase(Locale.ROOT))
if (loggerName == ROOT_LOGGER) {
- Configurator.setAllLevels(LogManager.ROOT_LOGGER_NAME, level)
+ Configurator.setLevel(LogManager.ROOT_LOGGER_NAME, level)
true
} else {
if (loggerExists(loggerName) && level != null) {
- Configurator.setAllLevels(loggerName, level)
+ Configurator.setLevel(loggerName, level)
true
}
else false
}
}
override def unsetLogLevel(loggerName: String): Boolean = {
+ val nullLevel: String = null
Review Comment:
Interesting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org