and the doc is quite unclear as to why these prefe...
# ask-community
a
and the doc is quite unclear as to why these prefect loggers exist, it just mentions that they exist so I assumed it's better to use them, but I have no idea what they actually do
n
Hi @Aurélien Vallée - the Prefect loggers do things related to Prefect, like tying logs to task, flow, and run information, sending (or not) logs to Server/Cloud based on log level etc. If you're curious to learn more about the logger, take a look at the logging util in Core.
upvote 1
a
Thanks Nicholas. Doesn't https://github.com/PrefectHQ/prefect/blob/08f005526b40e24ffb1440533b10728d235404cd/src/prefect/utilities/logging.py#L217 seems weird to you? A
sys.stdout
handler is directly attached to the logger, with a specific formatter. But 99% of the time, people already have a root handler, with their own formatter. This explains why I get duplicated log messages with different formatting. IMHO, attaching the
CloudHandler
should be enough for logs to be properly dispatched to server if the config says so, the extra stream handler interferes with the library user's logging configuration and causes repeated messages since messages are propagated upward to the root handler which will 99% of the time log them again. Didn't play with the code yet, just my understanding from reading the code so I can be wrong here. Will play with it tomorrow.
👍 1