Young Ho Shin
12/14/2022, 5:41 AMPREFECT_LOGGING_HANDLERS_CONSOLE_LEVEL=999 run_flow.py
would do the job, but this seems to turn off the logs on the web UI as well as the console.Bianca Hoch
12/14/2022, 8:50 PM~/.prefect/
# Prefect logging config file.
#
# Any item in this file can be overridden with an environment variable:
# `PREFECT_LOGGING_[PATH]_[TO]_[KEY]=VALUE`
#
# Templated values can be used to insert values from the Prefect settings at runtime.
version: 1
disable_existing_loggers: False
formatters:
simple:
format: "%(asctime)s.%(msecs)03d | %(message)s"
datefmt: "%H:%M:%S"
standard:
(): prefect.logging.formatters.PrefectFormatter
format: "%(asctime)s.%(msecs)03d | %(levelname)-7s | %(name)s - %(message)s"
flow_run_fmt: "%(asctime)s.%(msecs)03d | %(levelname)-7s | Flow run %(flow_run_name)r - %(message)s"
task_run_fmt: "%(asctime)s.%(msecs)03d | %(levelname)-7s | Task run %(task_run_name)r - %(message)s"
datefmt: "%H:%M:%S"
json:
class: prefect.logging.formatters.JsonFormatter
format: "default"
# filters:
# Define any custom filters to drops records containing
# sensitive information
# my_filter:
# class: your_module.FilterClass
handlers:
# The handlers we define here will output all logs they receieve by default
# but we include the `level` so it can be overridden by environment
orion:
level: 0
class: prefect.logging.handlers.OrionHandler
loggers:
prefect:
level: "${PREFECT_LOGGING_LEVEL}"
prefect.extra:
level: "${PREFECT_LOGGING_LEVEL}"
handlers: [orion]
prefect.flow_runs:
level: NOTSET
handlers: [orion]
prefect.task_runs:
level: NOTSET
handlers: [orion]
prefect.orion:
level: "${PREFECT_LOGGING_SERVER_LEVEL}"
prefect.client:
level: "${PREFECT_LOGGING_LEVEL}"
prefect.infrastructure:
level: "${PREFECT_LOGGING_LEVEL}"
uvicorn:
level: "${PREFECT_LOGGING_SERVER_LEVEL}"
fastapi:
level: "${PREFECT_LOGGING_SERVER_LEVEL}"
import logging
from prefect import flow, task, get_run_logger
@task
def test_task():
logger = get_run_logger()
<http://logger.info|logger.info>("abc")
@flow
def test_logging():
test_task()
if __name__ == "__main__":
test_logging()
#Deployment commands to enter in the terminal
#prefect deployment build ./disable_console_log.py:test_logging -n test-logging -q logging-queue
#prefect deployment apply ./test_logging-deployment.yaml
Young Ho Shin
12/15/2022, 3:05 AMlogging.yml
does seem to work.
I was also able to get the behavior I want (i.e. INFO levels logs on orion, but ERROR logs on console) by changing to level: ERROR
for the console handler in the default yml file.
I am still a bit confused why my original try of PREFECT_LOGGING_HANDLERS_CONSOLE_LEVEL=999 run_flow.py
does not work.
From the [docs](https://docs.prefect.io/concepts/logs/#logging-configuration) it seems like it should. I've tried PREFECT_LOGGING_HANDLERS_CONSOLE_LEVEL=ERROR
and PREFECT_LOGGING_HANDLERS_CONSOLE_LEVEL="ERROR"
, but this doesn't work either.