<@ULVA73B9P> when I surface other loggers via PREF...
# ask-marvin
j
@Marvin when I surface other loggers via PREFECT_LOGGING_EXTRA_LOGGERS I only get the warning layer. How would I get the Info layer as well for the extra loggers?
m
thought for 199.1 seconds
Yep —
PREFECT_LOGGING_EXTRA_LOGGERS
only attaches Prefect handlers to those loggers; it does not automatically lower their logger level to
INFO
. So if your extra logger inherits from the Python root logger, and the root logger is still
WARNING
, you'll only see warnings and above. Why this happens -
PREFECT_LOGGING_EXTRA_LOGGERS
adds handlers to the named logger(s) - but the logger’s effective level may still be
WARNING
- therefore
INFO
records are filtered before Prefect can emit them How to get INFO logs too Option 1: Set the extra logger level in code Do this before your flow runs / before logging is initialized:
Copy code
import logging
import os

os.environ["PREFECT_LOGGING_EXTRA_LOGGERS"] = "requests,urllib3"

logging.getLogger("requests").setLevel(<http://logging.INFO|logging.INFO>)
logging.getLogger("urllib3").setLevel(<http://logging.INFO|logging.INFO>)
That’s usually the simplest fix. Option 2: Set the root logger to INFO If you want all unconfigured loggers to emit INFO:
Copy code
export PREFECT_LOGGING_ROOT_LEVEL=INFO
export PREFECT_LOGGING_EXTRA_LOGGERS=requests,urllib3
This is broader, so it can make lots of third-party libraries noisier. Option 3: Use a custom logging config If you want precise control, define those loggers explicitly in a custom
logging.yml
and point Prefect at it with
PREFECT_LOGGING_CONFIG_PATH
. Example:
Copy code
version: 1
disable_existing_loggers: False

handlers:
  console:
    class: prefect.logging.handlers.PrefectConsoleHandler
    level: 0
    formatter: standard
    stream: <ext://sys.stderr>

  api:
    class: prefect.logging.handlers.APILogHandler
    level: 0

formatters:
  standard:
    (): prefect.logging.formatters.PrefectFormatter
    format: "%(asctime)s.%(msecs)03d | %(levelname)-7s | %(name)s - %(message)s"
    datefmt: "%H:%M:%S"

loggers:
  prefect:
    level: INFO

  requests:
    level: INFO
    handlers: [api]
    propagate: false

  urllib3:
    level: INFO
    handlers: [api]
    propagate: false

root:
  level: WARNING
  handlers: [console]
Recommendation If you only care about a few libraries, I’d use Option 1 and explicitly set:
Copy code
logging.getLogger("<name>").setLevel(<http://logging.INFO|logging.INFO>)
If you want, I can also give you a full working Prefect 3 example showing extra logger INFO logs appearing in a flow run.