Hi all! Can I ask if there's a way to setup custom log handlers on the prefect logger? I haven't tested it yet, but I'm pretty sure I can attach a handler, or check if a handler is already attached, when I call
prefect.context.get("logger")
, but is there a better place where I can hook up my own log handlers?
For example, we are going to write a log handler that can send agent/flow logs to a central location like kafka or s3 or datadog or whatever. We haven't exactly decided the target location yet, but we do know we want a central space, and I'm just trying to find the best place to configure and hook up our custom log handler.
z
Zanie
10/14/2021, 6:22 PM
Hi! This is a bit tricky since the logger can be shipped across different execution contexts. I'd recommend writing a wrapper for the
@task
decorator (or a
Task
subclass) that injects your custom log handler into the context for each task at runtime if it doesn't already exist.
If you happen to use ECS, you can configure this as log driver on your ECS task definition to send logs to a different place e.g to Splunk.
w
William Grim
10/22/2021, 4:02 AM
@Zanie Again, similar to the other thread, sorry for not ever responding. I somehow missed the notifications that anyone responded, but this is good info. In fact, it's very helpful, and I'm going to share it with our team.
William Grim
10/22/2021, 4:03 AM
@Anna Geller Same to you... I'm sorry I didn't notice you had responded. We don't use ECS, but we'll use the info earlier in the thread to create something. I appreciate it!
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.