https://prefect.io logo
#prefect-community
Title
# prefect-community
a

Amruth VVKP

04/29/2022, 1:29 PM
Hello community, I've got a quick question - what would be the best way to add a custom log handler to existing Orion or Prefect logs (I am on Prefect 2.0b3)?
g

Geoffrey Keating

04/29/2022, 1:34 PM
I asked something similar the other day - maybe this blog post could help? https://www.prefect.io/blog/logs-the-prefect-way/
upvote 1
a

Anna Geller

04/29/2022, 1:35 PM
Could you explain your use case? Do you want to attach a custom logger? if so, you could do that by adding an extra logger
Copy code
prefect config set PREFECT_LOGGING_EXTRA_LOGGERS=scipy
You may also adjust the log level used by specific Orion log handlers. E.g., you could set
PREFECT_LOGGING_HANDLERS_ORION_LEVEL=ERROR
to have only
ERROR
logs reported to Orion. The console handlers will still default to level
INFO
.
a

Amruth VVKP

04/29/2022, 1:40 PM
My usual configuration is to use a 3rd part logger like loguru, use it's sink to dump python native log handler's logs and attach a custom handler to redirect these logs into an external API. If I need to do a similar setup for Prefect Orion's logs - I was hoping I would be able to either attach the handler or dump the logs into Loguru's sink. Any suggestions?
a

Anna Geller

04/29/2022, 2:12 PM
Good question - loguru is super specific - you would need to add Prefect’s log handlers as loguru
sink
. This Discourse topic is for 1.0, but maybe it gives you some ideas on how to approach it in 2.0
a

Amruth VVKP

05/03/2022, 8:42 AM
Thanks @Anna Geller, this is helpful. let me give it a shot.
👍 1
I
5 Views