Del
11/18/2024, 8:28 PMMarvin
11/18/2024, 8:28 PMget_run_logger()
to access the logger within your flow or task. Here's a basic example of how you can implement logging in your flow:
python
from prefect import flow, get_run_logger
@flow
def my_flow():
logger = get_run_logger()
<http://logger.info|logger.info>("This is a log message for my_flow")
- View Logs in UI: Once your log is set up, you can view these logs in the Prefect Cloud UI or your self-hosted Prefect server. More details can be found in the Prefect 2.x documentation.
For Prefect 3.x, the process is quite similar:
- Use Prefect Logger: Like in 2.x, you can use get_run_logger()
from the prefect.logging
module to emit log messages.
This allows you to log messages that are aware of the current flow or task run context for more detailed information.
- Access Logs: Prefect automatically logs flow and task events, including state changes and errors, which you can access through the Prefect UI, CLI, or API. Need a more comprehensive approach? The 3.x documentation can offer further insights.
No existential angst here, just some useful logging insight!Nate
11/18/2024, 8:29 PMDel
11/18/2024, 8:30 PMDel
11/18/2024, 8:51 PMrich
for rendering the logs? My logs contain paths in square brackets [/path/to/something] and they're causing a rich.errors.MarkupError
@Nate @MarvinNate
11/18/2024, 9:04 PMNate
11/18/2024, 9:05 PM