gaurav narang
gaurav narang

Reputation: 21

Not getting proper logs on console with flink springboot gradle

I am trying to submit flink application locally in standalone mode and the job gets successfully submitted. I have modified log4j-console.properties and log4j.properties in the flink directory so that I can get logs appended to console. I can't see the logs on the console instead I am still getting it it the file which is created under log directory in flink. My build.gradle looks like this

dependencies {
    implementation 'org.apache.commons:commons-lang3:' + property('common-lang-version')
    implementation 'commons-io:commons-io:' + property('common-io-version')
    implementation('org.springframework.boot:spring-boot-starter-web') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
    implementation 'org.springframework.boot:spring-boot-starter-aop'
    implementation('org.springframework.boot:spring-boot-starter-actuator') {
        exclude group: 'io.micrometer', module: 'micrometer-core'
    }


    compileOnly 'org.apache.flink:flink-java:' + flinkVersion
    compileOnly 'org.apache.flink:flink-streaming-java:' + flinkVersion
    implementation 'org.apache.flink:flink-clients:' + flinkVersion
    implementation 'org.apache.flink:flink-connector-base:' + flinkVersion
    implementation 'org.apache.flink:flink-connector-kafka:' + flinkKafkaConnectorVersion
    implementation 'com.github.ben-manes.caffeine:caffeine'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'com.fasterxml.jackson.core:jackson-databind:' + property('jackson-version')

    runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}"
    runtimeOnly "org.apache.logging.log4j:log4j-api:${log4jVersion}"
    runtimeOnly "org.apache.logging.log4j:log4j-core:${log4jVersion}"
}

configurations.all {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}

test {
    useJUnitPlatform()
}

shadowJar {
    zip64 true

    mergeServiceFiles()
    manifest {
        attributes 'Main-Class': 'com.test.StreamingListenerMain'
    }

    append 'META-INF/spring.tooling'
    transform(PropertiesFileTransformer) {
        paths = ['META-INF/spring.factories']
        mergeStrategy = "append"
    }
    transform(AppendingTransformer) {
        resource = 'reference.conf'
    }
    transform(AppendingTransformer) {
        resource = 'META-INF/spring.handlers'
    }
    transform(AppendingTransformer) {
        resource = 'META-INF/spring.schemas'
    }
    dependencies {
        exclude(dependency("org.apache.flink:force-shading"))
        exclude(dependency('com.google.code.findbugs:jsr305'))
        exclude(dependency('org.slf4j:.*'))
        exclude(dependency('org.apache.logging.log4j:.*'))
        exclude(dependency('org.springframework.boot.logging.log4j2:.*'))
    }
}

Also, when I cancel the job I get the log as

2025-03-01 13:23:22,733 SpringApplicationShutdownHook ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console: java.lang.IllegalStateException: Trying to access closed classloader. Please check if you store classloaders directly or indirectly in static fields. If the stacktrace suggests that the leak occurs in a third party library and cannot be fixed immediately, you can disable this check with the configuration 'classloader.check-leaked-classloader'. java.lang.IllegalStateException: Trying to access closed classloader. Please check if you store classloaders directly or indirectly in static fields. If the stacktrace suggests that the leak occurs in a third party library and cannot be fixed immediately, you can disable this check with the configuration 'classloader.check-leaked-classloader'.
    at org.apache.flink.util.FlinkUserCodeClassLoaders$SafetyNetWrapperClassLoader.ensureInner(FlinkUserCodeClassLoaders.java:189)
    at org.apache.flink.util.FlinkUserCodeClassLoaders$SafetyNetWrapperClassLoader.getResources(FlinkUserCodeClassLoaders.java:224)
    at org.apache.logging.log4j.util.LoaderUtil.findUrlResources(LoaderUtil.java:294)
    at org.apache.logging.log4j.util.LoaderUtil.findResources(LoaderUtil.java:275)
    at org.apache.logging.log4j.util.PropertyFilePropertySource.loadPropertiesFile(PropertyFilePropertySource.java:37)
    at org.apache.logging.log4j.util.PropertyFilePropertySource.<init>(PropertyFilePropertySource.java:32)
    at org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:428)
    at org.apache.logging.log4j.util.PropertiesUtil$Environment.<init>(PropertiesUtil.java:420)
    at org.apache.logging.log4j.util.PropertiesUtil.<init>(PropertiesUtil.java:64)
    at org.apache.logging.log4j.core.appender.ConsoleAppender$Target.getCharset(ConsoleAppender.java:88)
    at org.apache.logging.log4j.core.appender.ConsoleAppender$Target$1.getDefaultCharset(ConsoleAppender.java:72)
    at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:222)
    at org.apache.logging.log4j.core.appender.ConsoleAppender$Builder.build(ConsoleAppender.java:189)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1120)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1045)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1037)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:651)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:247)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:293)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:626)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:699)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:716)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:270)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:245)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
    at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.getLoggerContext(Log4J2LoggingSystem.java:401)
    at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.cleanUp(Log4J2LoggingSystem.java:382)
    at org.springframework.boot.context.logging.LoggingApplicationListener.cleanupLoggingSystem(LoggingApplicationListener.java:276)
    at org.springframework.boot.context.logging.LoggingApplicationListener$Lifecycle.stop(LoggingApplicationListener.java:469)
    at org.springframework.context.SmartLifecycle.stop(SmartLifecycle.java:117)
    at org.springframework.context.support.DefaultLifecycleProcessor.doStop(DefaultLifecycleProcessor.java:234)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$300(DefaultLifecycleProcessor.java:54)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.stop(DefaultLifecycleProcessor.java:373)
    at org.springframework.context.support.DefaultLifecycleProcessor.stopBeans(DefaultLifecycleProcessor.java:206)
    at org.springframework.context.support.DefaultLifecycleProcessor.onClose(DefaultLifecycleProcessor.java:129)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1067)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1021)
    at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:145)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:114)
    at java.base/java.lang.Thread.run(Thread.java:829)

Upvotes: 0

Views: 20

Answers (0)

Related Questions