Hi - I’d like some advice on having logs show up in Prefect Cloud as well as streamed locally to stderr/stdout (the latter being currently the case).
I currently have some code that is wrapped in tasks/flows which produces these logs (and has an associated
). I was hoping that I could perhaps add this as an extra logger to Prefect (or add Prefect’s logger as one of the handlers), resulting in getting logs in cloud and on local stderr.
Has anyone set up something similar to this before?
(I tried naively adding the package logger to Prefect’s
env var, but this doesn’t seem to have worked as expected).
this is where there is some package/module structure like
and a logger configured as
logger = logging.getLogger(__name__)
I was thinking about just using
and adding that as a handler to the logger in that module
or just grab the
directly as you say
btw - it’s also possible I’m testing this incorrectly - locally I’m just running the flow and was expecting to see these logs appear in the local Prefect log stream. Maybe that’s not right
Laura Lorenz (she/her)
2 years ago
Yes, I think if extra loggers isn’t working for some reason (which I’m going to try and reproduce) adding the CloudHandler directly is an option.Yes, if the extra loggers config was working correctly I believe you would see them in the local Prefect stdout log stream, because it would attach both a CloudHandler and a StreamHandler with your prefect config at the same time.