Is there a convenient way of logging inside normal...
# ask-the-community
g
Is there a convenient way of logging inside normal python tasks running on a remote cluster? Specifically just logging to
stdout
or somehow accessible on the Flyte web interface
Or rather I should ask why if I
print
something it does not appear in the output and how do I fix that?
Apparently
stderr
seems to work. Any idea why
stdout
won’t?
l
it should print in the pod log if you use
print
g
Which is why I am confused that it is not…
l
let me clarify
if you use
print
you should be able to see the logs by kubectl
if you use logger
g
Yes, which I am not able to unless I write to
stderr
l
the default version of flytekit is debug I guess, but you should change it to info by setting env
you can use logger and set the level to 20
g
if you use logger
Which logger?
l
flytekit
has its own logger
finding example
g
I’ve been searching this Slack and documentation for mention of some kind of logger and not coming up with anything… some kind of example or reference would be very appreciated!
l
ImageSpec(python_version="3.9.13", packages=[flytekit_package, flytekitplugins_spark_package], registry="localhost:30000", apt_packages=["git","wget"], env={"FLYTE_SDK_LOGGING_LEVEL": "20"},)
you can use imagespec, or add env to your dockerfile like this
you can print log by using this 2 lines
and remember to setup the env variable!
g
Thanks that works as expected!
c
I agree with Greg that the documentation around this could be improved. it took me a while to figure out how to log flytekit code
s
would you mind creating a docs issue? @Greg Linklater / @Chris Grass [flyte-docs]
s
cc @Nikki Everett
n
i didn't see an existing docs issue, so i went ahead and created one: https://github.com/flyteorg/flyte/issues/4830