Skip to content

[dagster pipes] How do i get log messages in the external process to output in stdout / stderr? #19203

Answered by alangenfeld
alangenfeld asked this question in Q&A
Discussion options

You must be logged in to vote

The log property on PipesContext is a logging.Logger so you can add your own handler like so:

import sys
import logging


with open_dagster_pipes(
    ...
) as pipes:
	handler = logging.StreamHandler(sys.stdout)
	handler.setLevel(logging.DEBUG)
	formatter = logging.Formatter('%(levelname)s - %(message)s')
	handler.setFormatter(formatter)
        pipes.log.addHandler(handler)
	
	pipes.log.info(f"Run ID: {pipes.run_id}")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@j-nierop
Comment options

Answer selected by alangenfeld
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: dagster-pipes Related to Dagster Pipes
2 participants