I saw on this website https://cloud.google.com/dataflow/docs/guides/logging that i can programmatically set logging behavior of the pipeline. In my case, there is a class from a third party dependency that is producing too much warning messages, so i want to set its logging level to ERROR only.
So what i did: (a bit different than what the website provided (out of date))
val sdkHarnessLogLevelOverrides = SdkHarnessLogLevelOverrides()
sdkHarnessLogLevelOverrides
.addOverrideForClass(
ThirdPartyClass::class.java,
SdkHarnessOptions.LogLevel.ERROR
)
val optionsWithLoggingConfiguration = options.`as`(SdkHarnessOptions::class.java)
optionsWithLoggingConfiguration.sdkHarnessLogLevelOverrides = loggingConfiguration
//I also want to set the default logging behavior for the rest to WARN level
optionsWithLoggingConfiguration.defaultSdkHarnessLogLevel = SdkHarnessOptions.LogLevel.WARN
val pipeline = Pipeline.create(optionsWithLoggingConfiguration)
But I still can see the WARN message from the ThirdPartyClass in the Stackdrive, which coming from dataflow_step in a dataflow worker.
I don't know what I did wrong here, the documentation is pretty out of dated and limited examples. Does anyone encounter this problem before? I would love to hear from you. Thank you very much.
Try using DataflowWorkerLoggingOptions.setWorkerLogLevelOverrides
Explanation: Dataflow currently can run in two different modes, which we call "v1" and "v2":
DoFn
code directly in the same process as the dataflow worker, so you use DataflowWorkerLoggingOptions.setWorkerLogLevelOverrides .--experiments=use_runner_v2
and will eventually become the default, the SDK harness runs your DoFn
code in a separate process from the highly optimized C++-based Dataflow v2 worker, so you use SdkHarnessOptions.setSdkHarnessLogLevelOverrides A bonus about the v2 approach is that this works on all modernized Beam runners, not just Dataflow, as the SDK harness that runs your DoFn
is a portable process that is the same regardless of runner that you choose.
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.