简体   繁体   中英

Unable to remove Spring Kafka logging

How can I change the logging for Springboot Kafka? I'm seeing over 2M messages on our Splunk server and nothing is working:

org.apache.kafka.clients.FetchSessionHandler=ERROR
logging.level.org.apache.kafka.clients.FetchSessionHandler=ERROR
org.apache.kafka=ERROR
logging.level.org.apache.kafka=ERROR
org.apache.kafka.clients.consumer.internals.ConsumerCoordinator=ERROR
logging.level.org.apache.kafka.clients.consumer.internals.ConsumerCoordinator=ERROR
logging.level.root=OFF

also tried:

logging.level.root=ERROR
logging.level.org.springframework.web=ERROR
logging.level.org.hibernate=ERROR
logging.level.org.apache.*=ERROR

Dependencies:

    kafkaVersion = "2.1.1"
    log4jVersion = "2.11.1"
    springBootGradlePluginVersion = "2.4.2"
    springBootVersion = "2.3.0.RELEASE"
    springJdbcVersion = "5.2.5.RELEASE"
    springWebVersion = "2.3.4.RELEASE"

        // Logging
        compile "org.slf4j:slf4j-jdk14"
        implementation "org.apache.logging.log4j:log4j-api:$log4jVersion"
        implementation "org.apache.logging.log4j:log4j-core:$log4jVersion"
        implementation group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2', version: "$log4jVersion"

        // Spring Dependencies
        compile group: "org.springframework.kafka", name: "spring-kafka", version: "$springBootVersion"
        compile group: "org.springframework", name: "spring-jdbc", version: "$springJdbcVersion"
        compile(group: "org.springframework.boot", name: "spring-boot-starter-web", version: "$springWebVersion") {
            exclude group: "ch.qos.logback", module: "logback-classic"
            exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
        }

None of this does anything. Am I missing something?

This works as expected for me:

plugins {
    id 'org.springframework.boot' version '2.3.11.RELEASE'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.apache.logging.log4j:log4j-api"
    implementation "org.apache.logging.log4j:log4j-core"
    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-log4j2'

    compile(group: "org.springframework.boot", name: "spring-boot-starter-web") {
        exclude group: "ch.qos.logback", module: "logback-classic"
        exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
    }

    implementation 'org.springframework.kafka:spring-kafka'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation 'org.springframework.kafka:spring-kafka-test'
}

test {
    useJUnitPlatform()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM