Skip to content

[Feature Request]: Add a native Logging transform to Java SDK #38528

@ahmedabu98

Description

@ahmedabu98

What would you like to happen?

AFAIK the Java SDK doesn't have an easy utility to print/log the outputs of a PCollection. I've always had to hack something together like:

    rows.apply(MapElements.into(strings()).via(row -> {
      System.out.println("row: " + row);
      return "";
    }));

Would be nice to have an easy utility that can be used like:

    rows.apply(Log.info());

The Python SDK has something like this:

class LogElements(PTransform):
"""
PTransform for printing the elements of a PCollection.
Args:
label (str): (optional) A custom label for the transform.
prefix (str): (optional) A prefix string to prepend to each logged element.
with_timestamp (bool): (optional) Whether to include element's timestamp.
with_window (bool): (optional) Whether to include element's window.
level: (optional) The logging level for the output (e.g. `logging.DEBUG`,
`logging.INFO`, `logging.WARNING`, `logging.ERROR`). If not specified,
the log is printed to stdout.
with_pane_info (bool): (optional) Whether to include element's pane info.
use_epoch_time (bool): (optional) Whether to display epoch timestamps.
"""

Issue Priority

Priority: 2 (default / most feature requests should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Infrastructure
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Prism Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions