谷歌云数据流eclipse插件无法在配置时显示TRACE日志或任何低于错误的日志

时间:2016-06-01 16:11:35

标签: google-cloud-dataflow

当我配置google云数据流eclipse插件时,我无法看到日志,这是将workerLogLevelOverrides设置为{\“com.mycompany.testdataflow.StarterPipeline \”:\“TRACE \”}

奇怪的是,这个配置为ERROR级别似乎显示日志,但任何更低的不是。

有人能碰到过这个吗?

以下是我用来尝试输出日志的代码段

private static final Logger LOG = LoggerFactory.getLogger(StarterPipeline.class);

public static void main(String[] args) {
    Pipeline p = Pipeline.create(PipelineOptionsFactory.fromArgs(args).withValidation().create());

    for (String string : args) {
        // System.out.println("########## "+string);
        LOG.trace("Doing the trace for pipeline ##### Parameter is #### " + string);

        LOG.trace("Doing the trace for pipeline ##### Parameter is #### ");
    }

    LOG.trace("Doing the trace for pipeline");
    p.apply(Create.of("Hello", "World")).apply(ParDo.of(new DoFn<String, String>() {
        @Override
        public void processElement(ProcessContext c) {
            LOG.trace("Doing the trace for pipeline");
            c.output(c.element().toUpperCase());
        }
    })).apply(ParDo.of(new DoFn<String, Void>() {
        @Override
        public void processElement(ProcessContext c) {
            LOG.trace("Doing the trace for pipeline");
            LOG.info(c.element());
        }
    }));

这是来自数据流示例,除了我添加的日志记录,以查看我是否能够看到任何日志。

1 个答案:

答案 0 :(得分:1)

使用BlockingDataflowPipelineRunnerDataflowPipelineRunner运行管道时,有两个部分需要执行。首先,您的main方法在您的机器上本地运行以生成管道。当您调用p.run()时,管道将被发送到Dataflow服务,在该服务上运行(可能很多)虚拟机。

直接在main方法中的日志语句(例如“为管道执行跟踪...”)会在您的计算机上发生,并显示在Eclipse控制台中。 DoFn内的日志语句发生在虚拟机上,并且只显示在云日志记录中,如DebuggingWordCount example中所述。

指定workerLogLevelOverrides会影响工作虚拟机的日志级别。因此,更改该值将影响DoFn记录到Cloud Logging的内容。

要调整计算机上运行的代码的日志级别(所以main方法),您需要调整运行主程序的SLF4J或java.util.logging日志级别。例如,these instructions on Stack Overflow建议使用日志配置文件。