Elliott Wilson
08/07/2025, 2:54 PMMarvin
08/07/2025, 2:54 PMMarvin
08/07/2025, 2:54 PMbash
export PREFECT_SERVER_LOGGING_LEVEL=WARNING # or INFO, ERROR, etc.
2. Update your logging configuration:
If you have a custom logging.yml
file (typically in ~/.prefect/logging.yml
), you need to update it to use the correct variable name. Change:
yaml
loggers:
prefect:
level: "${PREFECT_LOGGING_SERVER_LEVEL}"
to:
yaml
loggers:
prefect:
level: "${PREFECT_SERVER_LOGGING_LEVEL}"
The error occurs because there was a change in the environment variable naming convention. The correct variable name is PREFECT_SERVER_LOGGING_LEVEL
(not PREFECT_LOGGING_SERVER_LEVEL
).
Common logging levels you can use are:
- INFO
- WARNING
- ERROR
- DEBUG
For production environments, WARNING or ERROR are typically recommended.
Would you like me to help you with any specific logging level configuration or do you need clarification on any part of the solution?Elliott Wilson
08/07/2025, 2:57 PMMarvin
08/07/2025, 2:59 PMMarvin
08/07/2025, 3:00 PMpython
flow.deploy(
name="your-deployment",
job_variables={
"env": {
"PREFECT_LOGGING_LEVEL": "INFO",
"PREFECT_CLIENT_LOGGING_LEVEL": "INFO",
"PREFECT_SERVER_LOGGING_LEVEL": "INFO",
"PREFECT_LOGGING_SETTINGS_PATH": "/usr/flows/logging.yml"
}
}
)
2. Use a Custom Logger in Your Flows:
A more robust solution would be to use Prefect's built-in logging utilities in your flows:
python
from prefect import flow, get_run_logger
@flow
def your_flow():
logger = get_run_logger()
<http://logger.info|logger.info>("This will be properly logged")
# Your flow logic here
@flow
def your_subflow():
logger = get_run_logger()
<http://logger.info|logger.info>("This will be properly logged in the subflow")
# Your subflow logic here
3. Modify Your logging.yml:
Make sure your logging.yml file has a default fallback if the environment variable isn't set:
yaml
loggers:
prefect:
level: ${PREFECT_SERVER_LOGGING_LEVEL:-INFO} # This provides a default of INFO if the var isn't set
handlers: [console]
propagate: false
4. Ensure Volume Mounting:
Make sure your logging.yml file is properly mounted in the subflow containers:
dockerfile
VOLUME /usr/flows
Could you share:
1. How are you calling the subflow? (Is it in the same flow file or imported?)
2. Are you using any specific deployment infrastructure for the subflows?
This would help me provide a more targeted solution for your specific setup.Elliott Wilson
08/07/2025, 3:02 PMMarvin
08/07/2025, 3:02 PMMarvin
08/07/2025, 3:03 PMpython
import os
from prefect import flow, task, get_run_logger
@flow
def debug_flow():
logger = get_run_logger()
<http://logger.info|logger.info>("Checking environment variables:")
for key in os.environ:
if key.startswith('PREFECT_'):
<http://logger.info|logger.info>(f"{key}: {os.environ[key]}")
@flow
def main_flow():
debug_flow()
# rest of your flow
2. Modify your logging.yml to use fallbacks:
yaml
version: 1
disable_existing_loggers: False
formatters:
standard:
(): prefect.logging.formatters.PrefectFormatter
format: "%(asctime)s.%(msecs)03d | %(levelname)-7s | %(name)s - %(message)s"
handlers:
console:
class: prefect.logging.handlers.PrefectConsoleHandler
formatter: standard
level: ${PREFECT_LOGGING_LEVEL:-INFO}
loggers:
prefect:
level: ${PREFECT_SERVER_LOGGING_LEVEL:-INFO}
handlers: [console]
propagate: false
root:
level: ${PREFECT_LOGGING_LEVEL:-INFO}
handlers: [console]
3. Ensure environment variables are set in your Docker run command:
bash
docker run \
-e PREFECT_LOGGING_LEVEL=INFO \
-e PREFECT_CLIENT_LOGGING_LEVEL=INFO \
-e PREFECT_SERVER_LOGGING_LEVEL=INFO \
-e PREFECT_LOGGING_SETTINGS_PATH=/usr/flows/logging.yml \
your-image-name
4. Use explicit logging in your tasks:
python
from prefect import task, get_run_logger
@task
def your_task():
logger = get_run_logger()
<http://logger.info|logger.info>("Starting task execution")
# your task logic here
Could you try these steps and let me know:
1. What does the debug_flow output show?
2. Are you running this in a local Docker container or in a cloud environment?
3. Could you share a bit more about how the task is imported? (Is it from another file in the same directory, or from a package?)
This information would help me provide a more targeted solution for your specific setup.