https://flyte.org logo
t

Tom Szumowski

08/02/2022, 7:30 PM
Hi! Question on Logging. I'm running on GCP (configured using Opta + some customizing). I noticed I am only getting logs from
print
statements in my tasks, but not
<http://logging.info|logging.info>
. I was wondering what's needed to set up logging for GCP (GKE). I found this document, but wasn't sure what settings would be appropriate for GCP. FIgured I'd check here first before diving too deep. https://docs.flyte.org/projects/cookbook/en/latest/auto/deployment/configure_logging_links.html#sphx-glr-auto-deployment-configure-logging-links-py Thank you!
k

Ketan (kumare3)

08/02/2022, 7:59 PM
logging.info logs probably needs some log level to be set - cc @Yee
y

Yee

08/02/2022, 9:07 PM
@Tom Szumowski do you have a sec to talk about this?
t

Tom Szumowski

08/02/2022, 9:20 PM
@Yee were you thinking voice or slack message? I can slack but can't do voice right now.
@Ketan (kumare3) you were correct, thank you! It appears I forgot to set up the logger. Specifically, I needed to set up the logger from somewhere inside the workflow execution, i.e. inside the
@workflow
function is good for me.
Copy code
@workflow
def my_wf(a: int, b: str) -> Tuple[int, str]:
    logging.basicConfig(
        format="%(asctime)s %(levelname)-8s %(module)s - %(funcName)s: %(message)s",
        level=<http://logging.INFO|logging.INFO>,
        datefmt="%Y-%m-%d %H:%M:%S"
    )
The screenshot shows it showing up in Google Cloud Logging (see "Hello from t1: B")
k

Ketan (kumare3)

08/03/2022, 1:44 PM
Workflow is not executed at runtime
t

Tom Szumowski

08/03/2022, 1:46 PM
@Ketan (kumare3) Would that imply that the code addition of
logging.basicConfig(...)
should not have solved the issue then?
k

Ketan (kumare3)

08/03/2022, 1:54 PM
No so it did, just that it was almost like luckily the same module was loaded and workflows are module loading time constructs
You can add it to some init module?
t

Tom Szumowski

08/03/2022, 2:04 PM
Good call. I'll do that. đź‘Ť
y

Yee

08/03/2022, 2:13 PM
we need to clean up our logging docs
t

Tom Szumowski

08/03/2022, 2:13 PM
Just added to init.py and that worked.
y

Yee

08/03/2022, 2:13 PM
yeah it will
but you shouldn’t need to do that
there’s a fair number of loggers already configured in flytekit.
and here should be one attached to flytekit.current_context().logger
by default yeah, the python logging module will not be at the info level.
and to set the level for all the loggers you can use the
FLYTE_SDK_LOGGING_LEVEL
env var. just set that to 10 and you should get everything including debug
i thought your question was more on how to get the link to the gcp logging page hooked up properly so that when you click on the log link, the url has the right filters to show your pod’s logs
that will take a backend change to config
t

Tom Szumowski

08/03/2022, 2:19 PM
which takes a backend change to config? the gcp logging page" Or default value for
FLYTE_SDK_LOGGING_LEVEL
?
k

Ketan (kumare3)

01/04/2023, 2:48 AM
Why not simply import logging?
d

Dave Liu

01/06/2023, 6:05 PM
So I solved this when I realized that my original logging wasn’t setting the
BasicConfig(force=True)
3 Views