Rion Williams
02/21/2024, 3:07 PMlogConfiguration:
log4j-console.properties: |+
rootLogger.level = INFO
rootLogger.appenderRef.console.ref = ConsoleAppender
rootLogger.appenderRef.rolling.ref = RollingFileAppender
# console logs go to gcp logging so we want json format
appender.console.name = ConsoleAppender
appender.console.type = CONSOLE
appender.console.layout.type = JsonTemplateLayout
appender.console.layout.eventTemplateUri = classpath:GcpLayout.json
# log to file so logs show up in flink ui
appender.rolling.name = RollingFileAppender
appender.rolling.type = RollingFile
appender.rolling.append = false
appender.rolling.fileName = ${sys:log.file}
appender.rolling.filePattern = ${sys:log.file}.%i
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=100MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 10
However, when the job runs it immediately crashes with the following series of errors:
ERROR Null object returned for CONSOLE in Appenders
ERROR Unable to locate appender "ConsoleAppender" for logger config "root"
ERROR Unable to locate plugin type for JsonTemplateLayout
ERROR Unable to locate plugin for JsonTemplateLayout
ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.ConsoleAppender for element CONSOLE: java.lang.NullPointerException java.lang.NullPointerException
...
ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.ConsoleAppender for element CONSOLE: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.ConsoleAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.ConsoleAppender
Is there any additional configuration or plug-ins required to make this work/supported? The logging works when the job is run directly in IntelliJ locally, however I suspect that the Maven Shading process might be hiding these specific references?Rion Williams
02/21/2024, 8:13 PMRion Williams
02/21/2024, 8:19 PMUnable to locate plugin type for JsonTemplateLayoutRion Williams
02/21/2024, 10:30 PMERROR Unable to locate plugin type for JsonTemplateLayout ERROR Unable to locate plugin for JsonTemplateLayout ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.ConsoleAppender for element Console: java.lang.NullPointerException java.lang.NullPointerException
The logConfiguration for the job looks as follows:
logConfiguration:
log4j-console.properties: |+
rootLogger.level = INFO
rootLogger.appenderRef.console.ref = ConsoleAppender
rootLogger.appenderRef.rolling.ref = RollingFileAppender
...
appender.console.name = ConsoleAppender
appender.console.type = Console
appender.console.layout.type = JsonTemplateLayout
appender.console.layout.eventTemplateUri = classpath:GcpLayout.json
I believe that all of the appropriate references are correct in the actual shaded jar itself as I can see things like the JsonTemplateLayout inside of it (under org.apache.logging.log4j.template.json.JsonTemplateLayout ) as well as the GcpLayout that I’m targeting in the root of the shaded jar as well (see attached image)
I’ve tried adjusting several different knobs/configurations but I’m still continually getting this same error. I’d be happy to share any additional configuration for the job any/or the FlinkDeployment where applicable. Just a bit stumped here.Prithvi Dammalapati
02/22/2024, 4:12 PMPrithvi Dammalapati
02/22/2024, 4:13 PMlog4j-console.properties: | instead of log4j-console.properties: |+ and make sure you provide all necessary properties in thereRion Williams
02/22/2024, 4:53 PM/flink/lib directory.
I think the problem here is that I have an initContainer that handles copying the job from the original image onto the image the operator is running against (i.e. flink-1.17) to expose the jar, however I feel like I need to do the same for this logging dependency as well (but I don’t see any options as far as copying over custom libs like that), I’m using the ENABLE_BUILT_IN_PLUGINS functionality for some things and this feels slightly similar.Rion Williams
02/22/2024, 10:32 PM/flink/lib directory for the image that the operator uses. I attempted to accomplish this via a volume/volumeMount as follows:
podTemplate:
apiVersion: v1
kind: Pod
metadata:
name: task-manager-pod-template
spec:
initContainers:
- name: copy-job-contents
image: {{ $.Values.myCustomFlinkImage }}
volumeMounts:
- mouthPath: /flink/lib
name: lib
command: ["/bin/sh", "-c"]
args:
- cp /my/image/example.jar /flink/lib/example.jar
- ...
...
containers:
- name: flink-main-container
...
volumeMounts:
- mountPath: /flink/lib
name: lib
...
volumes:
- name: lib
emptyDir: { }
However, when I attempt something like this it looks like the volume being mounted completely overwrites the lib directory causing the necessary Flink components to be unavailable (since /flink/lib is an actual non-empty active directory), so it’d be overwriting that with the volume.
Is there any other way to add something to the class path at a given location (other than /flink/lib) when using the operator so that I could make something like this available?Gyula Fóra
02/23/2024, 7:08 AMPrithvi Dammalapati
02/23/2024, 1:42 PMvolumes:
- name: config
configMap:
# Provide the name of the ConfigMap you want to mount.
name: flink-logging
# An array of keys from the ConfigMap to create as files
items:
- key: "log-layout.json"
path: "log-layout.json"
Each pod will then refer to this in its log configuration
appender.console.layout.type = JsonTemplateLayout
appender.console.layout.eventTemplateUri = file:///config/log-layout.json