Reputation: 1322
I have a very basic Flask app set up in a Google App Engine:
from flask import Flask
app = Flask(__name__)
@app.route("/<id>")
def hello(id):
print("Got this id: {}".format(id))
return "Hello World: {}".format(id)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8080, debug=True)
I have enabled logging by running this in my terminal: gcloud beta tasks queues update [QUEUE_ID] --log-sampling-ratio=1.0
I am intentionally triggering an error by adding a POST request to my Flask endpoint. I see in my queue that this task retries many times, but when I click on the logs, I see this (task name and queue name intentionally modified for this screenshot):
I am expecting to see the error that I get from gcloud app logs read
, which is:
2019-11-18 16:27:59 default[20191118t002408] "POST /example_task_handler" 405
What am I doing wrong?
Update: I do see the logs I am looking for in the Google App Engine logs, but I don't see anything when I click on the logs for the individual failing POST Request task that gets retried.
Upvotes: 4
Views: 2574
Reputation: 1322
It turns out the issue was twofold.
logging
library, so I switched to logging.info('Got this id: {}'.format(id))
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
(this works because DEBUG is the lowest logging level).
Upvotes: 3
Reputation: 921
gcloud beta tasks queues update [QUEUE_ID] --log-sampling-ratio=1.0
?Another way of finding logs is with the Cloud Tasks Queue
selector in Stackdriver.
Upvotes: 2