<@ULVA73B9P> Can I add an entry into a flow run's ...
# ask-marvin
j
@Marvin Can I add an entry into a flow run's logs on the Prefect UI after the flow run has finished?
m
It seems that adding log entries to a flow run after it has completed is not directly supported in Prefect. Once a flow run is completed, its logs are finalized, and there isn't a built-in feature to modify or append to these logs post-execution. The Prefect documentation and GitHub issues do not mention a way to alter logs after completion. However, you might consider logging externally if you need to capture additional information after the flow run. This could involve using an external logging service or database where you can append logs independently of Prefect's native logging system. For more details on Prefect's logging capabilities, you can explore the flow engine source code for insights into how logging is handled during flow execution.
j
@Marvin If I implement a separate logging solution (for example, aggregate parent flow and sub-flow logs), how can I have these logs be reflected in the Prefect UI?
m
To have your custom logging solution reflected in the Prefect UI, you can consider the following approach: 1. Custom Logging Configuration: Prefect allows you to customize its logging configuration by providing your own
logging.yml
file. This file can be placed in your
PREFECT_HOME
directory. By configuring this file, you can direct logs from your custom solution to be included in Prefect's logging system. 2. Root Logger: You can configure the root Python logger to capture logs from your custom logging solution. This involves setting the
PREFECT_LOGGING_ROOT_LEVEL
environment variable to ensure that all logs, including those from external sources, are captured. 3. Extra Loggers: Use the
PREFECT_LOGGING_EXTRA_LOGGERS
setting to include logs from other libraries or custom loggers. You can specify the names of the libraries or custom loggers you want Prefect to capture. For more details on how to configure logging in Prefect, you can refer to the Prefect logging documentation. By integrating your custom logging with Prefect's logging configuration, you can ensure that all relevant logs are displayed in the Prefect UI, providing a comprehensive view of your flow executions.