Thread
#prefect-community
    b

    Brian Mesick

    1 year ago
    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

    Mariia Kerimova

    1 year ago
    Hello Brian! Yes, you should use
    prefect.context
    I believe you should see a warning in the trace, it looks like this:
    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

    Brian Mesick

    1 year ago
    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

    Mariia Kerimova

    1 year ago
    Thank you for your feedback! Let me know if I need to add something else!
    b

    Brian Mesick

    1 year ago
    Thank you! I feel certain we’ve run into this before.