Xinglin Qiang
07/09/2024, 2:29 AMPREFECT_LOGGING_[PATH]_[TO]_[KEY]?
Marvin
07/09/2024, 2:29 AMPREFECT_LOGGING_[PATH]_[TO]_[KEY]?
. However, I found a relevant code example for logging configuration in a flow:
python
from prefect import flow
@flow(log_prints=True) # send `print` statements as INFO logs
def my_workflow():
print("I can call any python code here, including prefect tasks or flows")
if __name__ == "__main__":
my_workflow() # call it like a normal python function
# or serve it as a long-lived process
# my_workflow.serve("my-deployment-name")
(Link to source here)
Let me refine the search for the specific documentation you requested.
Oh joy, another glitch. Let's try a different strategy to fetch the information about configuring logging keys in Prefect. One moment.
Here's what I found in the GitHub issues related to Prefect logging configuration:
1. Issue: Importing prefect kills uvicorn
app's log messages
Prefect's logging setup seems to interfere with `uvicorn`'s default logging. More details here.
2. Issue: Adding logging attributes raises error when running on dask
There was a problem with setting PREFECT__LOGGING__LOG_ATTRIBUTES
, where users try to add extra log attributes and face issues. Details can be found here.
Let's illustrate a configuration snippet from the second issue:
Start your agent with the required logging attributes:
bash
PREFECT__LOGGING__LOG_ATTRIBUTES="['uuid']" PREFECT__LOGGING__FORMAT="%(message)s | %(uuid)s" ipython
Then in your Prefect task or flow:
python
import prefect
logger = prefect.utilities.logging.get_logger()
with prefect.context(uuid="42"):
logger.debug("hi")
This will produce the expected log output:
hi | 42
You can refer to the issue link for more detailed context and troubleshooting.
Hopefully, this helps in configuring your logging in Prefect correctly. If you have more specific details or need further assistance, feel free to ask!Xinglin Qiang
07/09/2024, 2:31 AMXinglin Qiang
07/09/2024, 2:32 AMMarvin
07/09/2024, 2:32 AMloggers.prefect.flow_runs
to DEBUG
.
However, based on general logging configurations of Prefect, you can set the logging level using environment variables.
Try setting the following environment variable:
bash
PREFECT_LOGGING__LEVEL="DEBUG"
If this needs to be specifically for loggers.prefect.flow_runs
, you might need a more granular configuration:
bash
PREFECT_LOGGING__LOGGERS__prefect__flows__LEVEL="DEBUG"
This approach follows the naming convention used in Prefect's logging setup, but due to the lack of documentation verification, please verify by testing in your environment.
For more precise details, you might want to delve directly into Prefect's logging utilities or configuration documentation once the systems behave properly.
If you encounter further issues or if this configuration doesn't work as expected, let me know, and I'll attempt another search or suggest additional methods.