ppkarwasz commented on code in PR #17373: URL: https://github.com/apache/kafka/pull/17373#discussion_r1819834263
########## config/log4j2.properties: ########## @@ -0,0 +1,163 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +# Unspecified loggers and loggers with additivity=true output to server.log and stdout +# Note that INFO only applies to unspecified loggers, the log level of the child logger is used otherwise +name=LogConfig +appenders=stdout,kafkaAppender,stateChangeAppender,requestAppender,cleanerAppender,controllerAppender,authorizerAppender + +# Console appender (stdout) +appender.stdout.type=Console +appender.stdout.name=STDOUT +appender.stdout.layout.type=PatternLayout +appender.stdout.layout.pattern=[%d] %p %m (%c)%n Review Comment: Have you considered switching to a structured configuration format like XML or YAML? The properties configuration format is not the default one and is not even one of the original ones (it appeared in version 2.4). It has [a lot of quirks](https://logging.apache.org/log4j/2.x/manual/configuration.html#java-properties-features) to make it easier to read, but also harder to understand. The XML format does not require additional dependencies. YAML only requires [`jackson-dataformat-yaml`](https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.16.2) that will only take an additional 400 KiB in Kafka's distribution. In YAML the configuration file would look like: ```yaml # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # 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. # Unspecified loggers and loggers with additivity=true output to server.log and stdout # Note that INFO only applies to unspecified loggers, the log level of the child logger is used otherwise Configuration: Properties: Property: # Fallback if the system property is not set - name: "kafka.logs.dir" value: "." - name: "logPattern" value: "[%d] %p %m (%c)%n%ex" # Appenders configuration # See: https://logging.apache.org/log4j/2.x/manual/appenders.html Appenders: Console: name: STDOUT PatternLayout: pattern: "${logPattern}" RollingFile: - name: KafkaAppender fileName: "${sys:kafka.logs.dir}/server.log" filePattern: "${sys:kafka.logs.dir}/server.log.%d{yyyy-MM-dd-HH}" PatternLayout: pattern: "${logPattern}" TimeBasedTriggeringPolicy: { } # State Change appender - name: StateChangeAppender fileName: "${sys:kafka.logs.dir}/state-change.log" filePattern: "${sys:kafka.logs.dir}/stage-change.log.%d{yyyy-MM-dd-HH}" PatternLayout: pattern: "${logPattern}" TimeBasedTriggeringPolicy: { } # Request appender - name: RequestAppender fileName: "${sys:kafka.logs.dir}/kafka-request.log" filePattern: "${sys:kafka.logs.dir}/kafka-request.log.%d{yyyy-MM-dd-HH}" PatternLayout: pattern: "${logPattern}" TimeBasedTriggeringPolicy: { } # Cleaner appender - name: CleanerAppender fileName: "${sys:kafka.logs.dir}/log-cleaner.log" filePattern: "${sys:kafka.logs.dir}/log-cleaner.log.%d{yyyy-MM-dd-HH}" PatternLayout: pattern: "${logPattern}" TimeBasedTriggeringPolicy: { } # Controller appender - name: ControllerAppender fileName: "${sys:kafka.logs.dir}/controller.log" filePattern: "${sys:kafka.logs.dir}/controller.log.%d{yyyy-MM-dd-HH}" PatternLayout: pattern: "${logPattern}" TimeBasedTriggeringPolicy: { } # Authorizer appender - name: AuthorizerAppender fileName: "${sys:kafka.logs.dir}/kafka-authorizer.log" filePattern: "${sys:kafka.logs.dir}/kafka-authorizer.log.%d{yyyy-MM-dd-HH}" PatternLayout: pattern: "${logPattern}" TimeBasedTriggeringPolicy: { } # Loggers configuration # See: https://logging.apache.org/log4j/2.x/manual/configuration.html#configuring-loggers Loggers: Root: level: INFO AppenderRef: - ref: STDOUT - ref: KafkaAppender Loggers: # Zookeeper logger - name: org.apache.zookeeper level: INFO # Kafka logger - name: kafka level: INFO # Kafka org.apache logger - name: org.apache.kafka level: INFO # Kafka request logger - name: kafka.request.logger level: WARN additivity: false AppenderRef: ref: RequestAppender # Uncomment the lines below and change log4j.logger.kafka.network.RequestChannel$ to TRACE # for additional output related to the handling of requests # - name: kafka.network.Processor # level: TRACE # additivity: false # AppenderRef: # ref: RequestAppender # - name: kafka.server.KafkaApis # level: TRACE # additivity: false # AppenderRef: # ref: RequestAppender # Kafka network RequestChannel$ logger - name: kafka.network.RequestChannel$ level: WARN additivity: false AppenderRef: ref: RequestAppender # KRaft mode controller logger - name: org.apache.kafka.controller level: INFO additivity: false AppenderRef: ref: ControllerAppender # ZK mode controller logger - name: kafka.controller level: TRACE additivity: false AppenderRef: ref: ControllerAppender # LogCleaner logger - name: kafka.log.LogCleaner level: INFO additivity: false AppenderRef: ref: CleanerAppender # State change logger - name: state.change.logger level: INFO additivity: false AppenderRef: ref: StateChangeAppender # Authorizer logger - name: kafka.authorizer.logger level: INFO additivity: false AppenderRef: ref: AuthorizerAppender ``` -- 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