2

I am trying to log within a cloud run service and all log summaries show up POST 0 B null ms curl/7.68.0 http://example.a.run.app/ which is not really informative and I need to expand each log to see what it is.

My code is the following and I am using bazel to build the container:

import logging
import os

from flask import Flask, make_response
import google.cloud.logging

app = Flask(__name__)

client = google.cloud.logging.Client()
client.setup_logging()


@app.route('/', methods=['POST'])
def hello_world():
  logging.warning('warning message')
  logging.info('info message')
  logging.error('error message')

  return make_response('OK', 200)


if __name__ == '__main__':
  app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))

enter image description here

other SO posts I am following to get log working:

Log to Cloud Logging with correct severity from Cloud Run Job and package used in the job

Google Cloud Functions Python Logging issue

EDIT: Logs show up fine on "Logs Explorer" but not on "Logs" under "Cloud Run"

Dokook Choe
  • 266
  • 2
  • 9
  • I have updated my answer below.please check – Sathi Aiswarya Jan 09 '23 at 08:39
  • I can confirm the issue. It is very annoying problem that makes me think if I should switch from using google.cloud.logging to native logging with stderr as output. I would loose the severity-filter, but checking the logs would still be faster (especially with small apps) – JuhaniTakkunen May 10 '23 at 06:50

1 Answers1

1

There is a bug raised for display textPayload (when it's present) instead of a URL in the initial collapsed view of an entry in the legacy log viewers at issue tracker. Which is still open, there is no update for a long time and the last update was to

right-click on the textPayload field, you can select "Add field to summary line" and this will be put in the collapsed summary line.

you may consider adding your concern in that issue tracker or raise a new issue tracker by referencing that thread further progress can be tracked there.

Sathi Aiswarya
  • 2,068
  • 2
  • 11