Hello community, I've got a quick question - what ...
# ask-community
a
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
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
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
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
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
Thanks @Anna Geller, this is helpful. let me give it a shot.
👍 1
I