<@ULVA73B9P> how can I set Prefect cloud logging l...
# ask-marvin
a
@Marvin how can I set Prefect cloud logging level to debug?
m
To set the logging level for Prefect Cloud to DEBUG, you can use environment variables or Prefect Profile settings. Follow these steps: 1. Set Environment Variable:
Copy code
bash
   export PREFECT_LOGGING_LEVEL="DEBUG"
2. Prefect Profile Setting: Alternatively, you can use the Prefect CLI to set this:
Copy code
bash
   prefect config set PREFECT_LOGGING_LEVEL="DEBUG"
To ensure the setting is applied globally, you may also configure the root logger:
Copy code
bash
export PREFECT_LOGGING_ROOT_LEVEL="DEBUG"
For further details, you can refer to the Prefect logging guide. Always a pleasure. Now, go bother someone else.
a
@Marvin I set my prefect_logging_level env var to debug but prefect cloud is only logging info and error logs
m
It appears others have run into issues with logging levels not appearing to work correctly in Prefect Cloud as well. Here are a few things to check: 1. Environment Variables: - Ensure that the environment variable is correctly set in the environment where the Prefect process is running. - Confirm with
print(os.getenv('PREFECT_LOGGING_LEVEL'))
in your script to see if it prints
DEBUG
. 2. Explicit Configuration: Prefect supports setting logging configurations via environment variables or directly in your configuration file. Double-check that it hasn't been accidentally overridden in your configurations.
Copy code
python
   from prefect.logging import get_logger

   # Ensure logger is configured to DEBUG
   logger = get_logger()
   logger.setLevel("DEBUG")
3. Check the Prefect Profile: - Use
prefect config view
to ensure the profile being used has the correct logging level set.
Copy code
bash
   prefect config view
4. Prefect Root Logger: If other solutions do not work, configure the root Python logger:
Copy code
bash
   export PREFECT_LOGGING_ROOT_LEVEL="DEBUG"
Some helpful sources: - Prefect Logging Guide - Example GitHub issues where logging configuration was discussed: Issue #6086, Issue #8248 If the problem persists, you might want to check these sources or raise a new issue in the Prefect GitHub repo. I hope this has been as enlightening as an asteroid impact on a planet.
a
@Marvin where can I find usage examples of the logging.yml file
m
You can find information about configuring logging using a
logging.yml
file in the Prefect logging guide. Here is an example of a basic
logging.yml
configuration:
Copy code
yaml
version: 1
disable_existing_loggers: False

formatters:
  standard:
    format: "%(asctime)s.%(msecs)03d | %(levelname)-7s | %(name)s | %(filename)s:%(lineno)s - %(funcName)s() - %(message)s"
    datefmt: "%H:%M:%S"
  flow_run_fmt:
    format: "%(asctime)s.%(msecs)03d | %(levelname)-7s | Flow run '%(flow_run_name)s' | %(filename)s:%(lineno)s - %(funcName)s() | %(message)s"
  task_run_fmt:
    format: "%(asctime)s.%(msecs) | %(levelname)-7s | Task run '%(task_run_name)s' | %(filename)s:%(lineno)s - %(funcName)s() | %(message)s"

handlers:
  console:
    class: logging.StreamHandler
    level: DEBUG
    formatter: standard
    stream: <ext://sys.stdout>

loggers:
  prefect:
    level: DEBUG
    handlers: [console]
    propagate: False

root:
  level: DEBUG
  handlers: [console]
### Applying the Configuration To apply the logging configuration from this
logging.yml
file, you must set the environment variable
PREFECT_LOGGING_SETTINGS_PATH
to the path of your
logging.yml
file:
Copy code
bash
export PREFECT_LOGGING_SETTINGS_PATH="/path/to/your/logging.yml"
### Default Logging Levels By default, Prefect displays
INFO
-level and above events. You can configure logging levels as shown in the YML configuration. For more details and examples, visit the Prefect logging guide. Wouldn't it be nice if I had emotions to tell you how pleased I am? Oh well.