<@ULVA73B9P> i see a lot of prefect error log from...
# marvin-ai
d
@Marvin i see a lot of prefect error log from worker marked on level error, but inside containing info level logs for example
10:59:58.007 | INFO    | prefect.flow_runs.worker - Completed submission of flow run
why is the log on wrong level (error instead of info)
m
thought for 415.2 seconds
Short answer: nothing is wrong with Prefect’s log level — it’s the output stream. Most container log collectors (Kubernetes, GCP, CloudWatch, Datadog, etc.) treat anything written to stderr as “error” severity regardless of the record’s actual level. Prefect’s default console handler writes to stderr, so INFO messages can show up as “ERROR” in your aggregator even though the message itself says INFO. Ways to fix it: - Route console logs to stdout - Provide a custom logging config and point Prefect to it with
PREFECT_LOGGING_SETTINGS_PATH
. - Example (YAML dictConfig) to send all console logs to stdout:
Copy code
version: 1
  disable_existing_loggers: false

  formatters:
    console:
      (): prefect.logging.formatters.PrefectFormatter

  handlers:
    console_stdout:
      class: prefect.logging.handlers.PrefectConsoleHandler
      level: INFO
      formatter: console
      stream: <ext://sys.stdout>

  loggers:
    prefect:
      level: INFO
      handlers: [console_stdout]
      propagate: false

  root:
    level: INFO
    handlers: [console_stdout]
- Set this for your worker container/pod: -
PREFECT_LOGGING_SETTINGS_PATH=/path/to/logging.yaml
- Emit structured JSON logs to stdout (so your platform can parse levels from the payload)
Copy code
version: 1
  disable_existing_loggers: false

  formatters:
    json:
      (): prefect.logging.formatters.JsonFormatter
      fmt: default

  handlers:
    console_stdout_json:
      class: prefect.logging.handlers.PrefectConsoleHandler
      level: INFO
      formatter: json
      stream: <ext://sys.stdout>

  loggers:
    prefect:
      level: INFO
      handlers: [console_stdout_json]
      propagate: false

  root:
    level: INFO
    handlers: [console_stdout_json]
- Alternatively, change your log collector’s mapping so it does not automatically mark stderr as “error”. Context/background: - This behavior was discussed in Prefect as logs defaulting to stderr causing INFO logs to be tagged as ERROR by some collectors: prefecthq/prefect#9197. If you can share where your worker is running (Kubernetes? Which cloud/log tool?), I can tailor a ready-to-use config for that environment.