Mario Pabon
09/11/2024, 2:43 PMMarvin
09/11/2024, 2:43 PMMario Pabon
09/11/2024, 2:43 PMMario Pabon
09/11/2024, 3:07 PMMarvin
09/11/2024, 3:08 PMget_run_logger
to get a logger instance.
- Example:
python
from prefect import flow, get_run_logger
@flow
def my_flow():
logger = get_run_logger()
<http://logger.info|logger.info>("This is a custom log message.")
2. ECS Configuration:
- Ensure ECS tasks can send logs to AWS CloudWatch.
- Set stream_output
and configure_cloudwatch_logs
to handle logs properly in ECS.
3. Connecting to Prefect Cloud:
- Use the Prefect CLI to set your API URL and key.
sh
prefect config set PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/[ACCOUNT-ID]/workspaces/[WORKSPACE-ID]>"
prefect config set PREFECT_API_KEY="[API-KEY]"
Useful Links:
- Prefect 3.0 Logging
- ECS Worker Guide
- Connecting to Prefect Cloud
For more specific errors, feel free to check these guides or provide version-specific details!Mario Pabon
09/11/2024, 3:09 PMMarvin
09/11/2024, 3:09 PMTrue
.
2. Set Environment Variables:
- Override the root logger's level and ensure it captures logs from other libraries.
sh
export PREFECT_LOGGING_ROOT_LEVEL="DEBUG"
3. Prefect Logger Configuration:
- Customize Prefect’s logging configuration via environment variables or settings.
sh
PREFECT_LOGGING_[PATH]_[TO]_[KEY]=value
- Example to set log level for flows:
sh
prefect config set PREFECT_LOGGING_LOGGERS_PREFECT_FLOW_RUNS_LEVEL="DEBUG"
### Sample Code:
python
import logging
from prefect import flow, get_run_logger
# Set up existing logger
existing_logger = logging.getLogger('my_existing_logger')
existing_logger.setLevel(logging.DEBUG)
existing_logger.propagate = True
@flow
def my_flow():
logger = get_run_logger()
<http://logger.info|logger.info>("This is a Prefect log message.")
existing_logger.debug("This is a debug message from existing logger.")
my_flow()
### Resources to Check:
- Prefect 2.x Logging Guide
- Prefect 3.x Logging
- Troubleshoot Prefect Cloud
By ensuring your custom loggers propagate their logs to the root logger, Prefect will capture and show them in the UI.Mario Pabon
09/11/2024, 3:33 PMMarvin
09/11/2024, 3:33 PM