ppkarwasz commented on code in PR #18496: URL: https://github.com/apache/kafka/pull/18496#discussion_r1931140927
########## core/src/main/scala/kafka/utils/LoggingController.scala: ########## @@ -27,22 +28,55 @@ import java.util.Locale import scala.jdk.CollectionConverters._ -object Log4jController { +object LoggingController { /** - * Note: In log4j, the root logger's name was "root" and Kafka also followed that name for dynamic logging control feature. + * Note: In Log4j 1, the root logger's name was "root" and Kafka also followed that name for dynamic logging control feature. * * The root logger's name is changed in log4j2 to empty string (see: [[LogManager.ROOT_LOGGER_NAME]]) but for backward- * compatibility. Kafka keeps its original root logger name. It is why here is a dedicated definition for the root logger name. */ val ROOT_LOGGER = "root" + private[this] val delegate: LoggingControllerDelegate = { + try { + new Log4jCoreController + } catch { + case _: ClassCastException | _: LinkageError => new NoOpController Review Comment: I would prefer to make a distinction between expected exceptions (`NoClassDefFound` if `log4j-api` absent, `ClassCastException` if `log4j-api` present but `log4j-core` is not the implementation used) and unexpected ones. Fixed in https://github.com/apache/kafka/pull/18496/commits/09a9131a1b98737ab2495fed5eb43d56203c80bd -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org