Robert
06/16/2024, 6:19 PMMarvin
06/16/2024, 6:19 PMPREFECT_LOGGING_LEVEL="DEBUG"
to capture debug level logs.
- Additionally, ensure the root Python logger’s level is set appropriately (e.g., PREFECT_LOGGING_ROOT_LEVEL="DEBUG"
).
You can read more about configuring log levels and handlers in Prefect here.
2. Scope of Logs:
- Flow and task logs are scoped to a flow and should be available in the Prefect UI.
- Worker logs are not scoped to a flow and are generally only available where the worker is running. This might explain why those logs are visible in the worker logs but not in the server UI.
3. Flow and Task Log Configuration:
- Ensure that you are logging print statements correctly. For flows, setting log_prints=True
will log print statements. For tasks, use the @task(log_prints=True)
decorator.
Example:
python
from prefect import task, flow
@task(log_prints=True)
def my_task():
print("Logging print statements from a task")
@flow(log_prints=True)
def my_flow():
print("Logging print statements from a flow")
my_task()
my_flow()
4. Known Issues:
- There are instances where logs may not appear in the UI due to certain bugs. For example, there's an issue where logs are not showing in the Cloud UI even though they are present in the CLI. You might be experiencing a related problem.
More details can be found in related GitHub issues:
- Logs not showing in Cloud UI: Created and completed
- Dask task scheduling hangs, then eventually flow fails with PoolTimeout
By adjusting your logging configuration and ensuring that you are capturing both flow and task-level logs correctly, you should be able to see them in the Prefect server UI. If the issue persists, it might be a bug that requires further investigation or a potential update of your Prefect version.
You can check the latest Prefect version and updates here.
Would you like further assistance or a deeper dive into any specific point?Robert
06/16/2024, 8:08 PMAPILogHandler
or use the Prefect logger with get_run_logger
:
from prefect.logging.handlers import APILogHandler
...
logger.addHandler(APILogHandler())
from prefect import get_run_logger
logger = get_run_logger()