I am seeing that writes to System.err map to an Error level logging event in GCP Logging. Is there any way to map these to a different logging level, such as Warning level?
In our code we always write to a SLF4J Logger but we are using 3rd party libraries that unfortunately write to System.err as well as throw exceptions. Since we have the exception, we don’t want to log the System.err as an error.
Update: It looks like Dataflow used to have a class com.google.cloud.dataflow.sdk.runners.worker.logging.DataflowWorkerLoggingInitializer that would allow me to configure stdout and stderr how I desire. Does anyone know why it was removed?
I would have configured it using the command line option:
--workerLogLevelOverrides={\"System.err":\"WARN\",\"System.out\":\"DEBUG\"}
Or the following code:
/**
* Maps the "System.err" and "System.out" loggers to desired levels.
* Note: the "System.err" and "System.out" logger are not currently part of the specification as of v1.5.1,
* so this is dependent on the current implementation of com.google.cloud.dataflow.sdk.runners.worker.logging.DataflowWorkerLoggingInitializer
* which does configure those loggers.
* @param options
*/
public static void setupSystemOutAndErrLogging(DataflowWorkerLoggingOptions options) {
WorkerLogLevelOverrides overrides = options.getWorkerLogLevelOverrides();
if ( overrides == null ) {
overrides = new WorkerLogLevelOverrides();
}
options.setWorkerLogLevelOverrides(
overrides.addOverrideForName("System.err", Level.WARN)
.addOverrideForName("System.out", Level.DEBUG));
}