<@ULVA73B9P> I have a flow that triggers a python ...
# ask-marvin
h
@Marvin I have a flow that triggers a python script which has its own logger. When I trigger this flow I see the logs in my terminal but not in the Prefect UI. What can be the issue? I already use
log_prints=True
in the flow decorator
m
To ensure the logs from your Python script are shown in the Prefect UI, you need to check a few things in your logging configuration. Here are some guidelines: 1. Log Level Configuration: Ensure the log level used by your script's logger is compatible with your Prefect logging settings. Prefect captures logs at specific levels (e.g.,
INFO
,
ERROR
). If your script logs at a lower level (like
DEBUG
), those logs might not be captured. 2. Root Logger Configuration: If you're using the root logger or other custom loggers, make sure their propagation is not disabled, which would prevent logs from reaching the Prefect handlers. Here are a few examples of setting up the logging configurations: ### Setting Environment Variables
Copy code
bash
export PREFECT_LOGGING_LEVEL="DEBUG"
export PREFECT_LOGGING_ROOT_LEVEL="DEBUG"
### Custom Logging Configuration File You can also customize logging by creating a
logging.yml
file and setting the logging configurations there. Here is an example snippet for a custom `logging.yml`:
Copy code
yaml
version: 1
disable_existing_loggers: False
formatters:
  simple:
    format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
handlers:
  console:
    class: logging.StreamHandler
    level: DEBUG
    formatter: simple
  api:
    class: prefect.logging.handlers.PrefectHandler
    level: DEBUG
loggers:
  # Python's root logger
  "":
    level: DEBUG
    handlers:
      - console
      - api
  # Your custom logger, if any
  my_custom_logger:
    level: DEBUG
    handlers:
      - console
      - api
    propagate: True
### Important References - Prefect Logging Guide If you still do not see logs in the Prefect UI after trying out these configurations, please review the Prefect logging settings and make sure your script loggers' configurations do not prevent logs from being captured by Prefect. If you need specific examples or further help, feel free to ask!
h
not working. there is no env var called:
PREFECT_LOGGING_ROOT_LEVEL