<@ULVA73B9P>, using Prefect 2.20.9, and with the f...
# ask-marvin
j
@Marvin, using Prefect 2.20.9, and with the following settings exported: PREFECT_LOGGING_ROOT_LEVEL=INFO PREFECT_LOGGING_LEVEL=INFO PREFECT_LOGGING_HANDLERS_API_LEVEL=INFO PREFECT_LOGGING_EXTRA_LOGGERS=library_1, library_2 PREFECT_LOGGING_SERVER_LEVEL=INFO I have found that logs sent to other loggers in a running process are captured by the Prefect console logger, but they are not sent to the Prefect server. Running
prefect flow-run logs <FLOW_RUN_ID>
shows that the logs that Prefect picked up in the console logger were not sent to the API. Default Prefect logs were still sent to the API and are available with the logs command and in the web UI. How can I ensure all logs sent to the console logger are also sent to the API?
m
To ensure that all logs sent to the console logger are also sent to the Prefect API in version 2.20.9, you may need to adjust your logging configuration. One of the key considerations is ensuring that all loggers are set up to propagate their logs appropriately. In the context of Prefect, the root logger is configured to collect logs from all sources unless they opt out by disabling propagation. Given your logs’ issue, it's likely that logs from additional loggers like
library_1
and
library_2
are not being correctly propagated to the Prefect server due to configuration issues. Here are the steps you can try to resolve this: 1. Check Logger Propagation: Ensure that the loggers for
library_1
and
library_2
have their
propagate
setting enabled. This ensures that their logs will be sent all the way up to the root logger. 2. Adjust Configuration: - Make sure your Prefect logging configuration doesn't filter out log levels that these libraries might be using. You have your log level set to
INFO
, so ensure that the libraries are not logging at a lower level. - Environment variables like
PREFECT_LOGGING_ROOT_LEVEL
and
PREFECT_LOGGING_LEVEL
should already be appropriately set for
INFO
. 3. Check the Prefect Server API Handler: Confirm that the Prefect server API handler is appropriately configured to receive logs and there are no additional setups required in your Prefect deployment. Here are the links to Prefect's guides on logging which may provide additional insights: - Logging configuration: Prefect 2.x Logging Guide If the above steps don't resolve the issue, consider checking for any configuration settings that might affect the API handler directly or open a discussion on Prefect's GitHub or community forum for more tailored advice.
j
These logs are propagated correctly, which I can see because they are sent to the Prefect console logger. They aren't sent to the API even though they appear in my console logger formatted as Prefect logs.