Hi all, question about logging… :thread:
# ask-community
b
Hi all, question about logging… 🧵
from prefect import context
logger = context.get("logger")
in a task seems to cause that task to not serialize while
import prefect
logger = prefect.context.get("logger")
 works
Is that expected behavior?
m
Hello Brian! Yes, you should use
prefect.context
I believe you should see a warning in the trace, it looks like this:
Copy code
TypeError: Pickling context objects is explicitly not supported. You should always access context as an attribute of the `prefect` module, as in `prefect.context`
b
Untitled
Running locally I just get that
It would be pretty cool if there was a reminder about that in the logging page: https://docs.prefect.io/core/concepts/logging.html#logging-configuration
m
Thank you for your feedback! Let me know if I need to add something else!
b
Thank you! I feel certain we’ve run into this before.