File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ use crate::crd::{
1515/// The JVM options selecting the Kafka log4j/log4j2 config file. Kafka 3.x uses log4j,
1616/// Kafka 4.0 and higher use log4j2.
1717pub fn kafka_log_opts ( product_version : & str ) -> String {
18- if product_version . starts_with ( "3." ) {
18+ if super :: properties :: uses_legacy_log4j ( product_version ) {
1919 format ! (
2020 "-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{log4j}" ,
2121 log4j = ConfigFileName :: Log4j
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ pub fn role_group_config_map_data(
4747 let mut configs: BTreeMap < String , Option < String > > = BTreeMap :: new ( ) ;
4848
4949 // Starting with Kafka 4.0, log4j2 is used instead of log4j.
50- match product_version . starts_with ( "3." ) {
50+ match super :: uses_legacy_log4j ( product_version ) {
5151 true => {
5252 configs. insert (
5353 ConfigFileName :: Log4j . to_string ( ) ,
Original file line number Diff line number Diff line change @@ -46,6 +46,16 @@ pub fn config_file_name(config: &AnyConfig) -> ConfigFileName {
4646 }
4747}
4848
49+ /// Whether the given Kafka version uses the legacy log4j logging framework.
50+ ///
51+ /// Kafka 3.x uses log4j ([`ConfigFileName::Log4j`]); Kafka 4.0 and later use log4j2
52+ /// ([`ConfigFileName::Log4j2`]). This is the single source of truth for that decision,
53+ /// used both when rendering the log config file and when selecting the JVM option that
54+ /// points at it.
55+ pub fn uses_legacy_log4j ( product_version : & str ) -> bool {
56+ product_version. starts_with ( "3." )
57+ }
58+
4959pub ( crate ) fn kraft_controllers ( pod_descriptors : & [ KafkaPodDescriptor ] ) -> Vec < String > {
5060 pod_descriptors
5161 . iter ( )
You can’t perform that action at this time.
0 commit comments