Christiano Christakou
02/12/2024, 4:50 PMScout
02/12/2024, 4:50 PMcontext
object. We provide a utility function called get_dagster_logger()
that allows you to get a Dagster-managed logger anywhere in your code. Here's how you can use it: python from dagster import get_dagster_logger def my_logged_function(): log = get_dagster_logger() for i in range(10): <http://log.info|log.info>("Did %d things!", i+1)
Messages produced this way will be treated identically to messages created using context.log
, resulting in a consistent logging experience. This feature is particularly useful when you’re converting existing code into the Dagster framework or when you want your logs to be captured by Dagster and linked to the relevant computations without modifying function signatures to pass around context. For more details, you can check out the documentation on [capturing Python logs](https://docs.dagster.io/concepts/logging/python-logging#capturing-python-logs).