Javier SG
11/05/2024, 4:16 PMMarvin
11/05/2024, 4:17 PMget_run_logger
from the prefect.logging
module. This logger is aware of the current flow or task run context, enabling detailed and contextual logging.
3. Configuration: If you wish to customize the logging behavior, such as changing log levels or outputs, you may need to adjust the Python logging configuration or provide a custom logging.yml
file in the PREFECT_HOME
directory. Prefect allows for extensive customizations using environment variables or configuration files.
Here's an example of how you might set this up in a simple flow with Loguru:
python
from prefect import flow, task
from prefect.logging import get_run_logger
from loguru import logger as loguru_logger
@task
def my_task():
<http://loguru_logger.info|loguru_logger.info>("Task started with Loguru")
logger = get_run_logger()
<http://logger.info|logger.info>("Task running with Prefect logger")
# ... task logic ...
@flow
def my_flow():
<http://loguru_logger.info|loguru_logger.info>("Flow started with Loguru")
my_task()
# Start the flow
if __name__ == "__main__":
my_flow()
- Documentation Links: For more detailed information about configuring Prefect logging, see the Prefect 3.x logging documentation.
Feel free to explore further customization of your logging setup to better fit your project's needs. Just remember, while logging is crucial, it's no substitute for having a good cup of tea while debugging!