<@ULVA73B9P> using the prefect logger, my info, wa...
# marvin-ai
e
@Marvin using the prefect logger, my info, warning, error and critical logs appear in the UI perfectly, but the debugs dont. why and how can make them appear? make a POC please Thanks
m
thought for 523.6 seconds
Short answer: In Prefect 3.x, the default logging level is INFO. That means DEBUG logs are filtered out before they’re sent to the API/UI. Raise the logging level to DEBUG and they’ll appear. How to enable DEBUG logs - One-off for a single run - Run your script with:
Copy code
PREFECT_LOGGING_LEVEL=DEBUG python your_flow.py
- Persistently (profile) - Save to your active Prefect profile:
Copy code
prefect config set logging.level=DEBUG
- Only bump flow/task loggers (keep everything else at INFO) - Set just these:
Copy code
export PREFECT_LOGGING_LOGGERS_PREFECT_FLOW_RUNS_LEVEL=DEBUG
    export PREFECT_LOGGING_LOGGERS_PREFECT_TASK_RUNS_LEVEL=DEBUG
Notes - Make sure the UI’s log level filter includes Debug. - API logging is on by default, but if you’ve changed it, ensure:
Copy code
PREFECT_LOGGING_TO_API_ENABLED=true
POC (copy/paste) 1) Local run POC (shows DEBUG in UI when enabled) Save as flow_debug_poc.py:
Copy code
from prefect import flow, task
from prefect.logging import get_run_logger

@task
def my_task():
    logger = get_run_logger()
    logger.debug("Task DEBUG appears when level=DEBUG")
    <http://logger.info|logger.info>("Task INFO")
    logger.warning("Task WARNING")
    logger.error("Task ERROR")
    logger.critical("Task CRITICAL")

@flow(name="debug-demo")
def debug_demo():
    logger = get_run_logger()
    logger.debug("Flow DEBUG appears when level=DEBUG")
    <http://logger.info|logger.info>("Flow INFO")
    logger.warning("Flow WARNING")
    logger.error("Flow ERROR")
    logger.critical("Flow CRITICAL")
    my_task()

if __name__ == "__main__":
    debug_demo()
Run it with DEBUG enabled:
Copy code
PREFECT_LOGGING_LEVEL=DEBUG python flow_debug_poc.py
2) Deployment/worker POC (two ways) Option A: Set DEBUG at the worker - Create a process work pool (once):
Copy code
prefect work-pool create "process-pool" --type process
- Start a worker with DEBUG in the environment:
Copy code
PREFECT_LOGGING_LEVEL=DEBUG prefect worker start --pool process-pool
- Deploy the flow (from the same directory as flow_debug_poc.py):
Copy code
python -c "from prefect.flows import Flow; Flow.from_source('.', 'flow_debug_poc.py:debug_demo').deploy(name='debug-demo', work_pool_name='process-pool')"
- Run the deployment:
Copy code
prefect deployment run debug-demo --watch
Option B: Set DEBUG on the deployment (no special worker env needed) - Deploy with an env override:
Copy code
python -c "from prefect.flows import Flow; Flow.from_source('.', 'flow_debug_poc.py:debug_demo').deploy(name='debug-demo', work_pool_name='process-pool', job_variables={'env': {'PREFECT_LOGGING_LEVEL':'DEBUG'}})"
- Start a normal worker:
Copy code
prefect worker start --pool process-pool
- Run the deployment:
Copy code
prefect deployment run debug-demo --watch
If you still don’t see DEBUG logs: - Double-check the UI filter for Debug - Confirm the process actually has
PREFECT_LOGGING_LEVEL=DEBUG
- For targeted control, try:
Copy code
PREFECT_LOGGING_LOGGERS_PREFECT_FLOW_RUNS_LEVEL=DEBUG
  PREFECT_LOGGING_LOGGERS_PREFECT_TASK_RUNS_LEVEL=DEBUG
e
thanks