I have an app in the Google App Engine Python 3 Standard Environment. I have it set up to group log entries by their request, as described in Writing Application Logs (in the "Viewing related request log entries" section).
That page notes:
The highest severity from the "child" log entries does not automatically apply to the top-level entry. If that behavior is desired, manually set the highest severity in the top-level entry.
The top-level entry in question is the request log that App Engine creates automatically. It's always at log level "Any". I'm not seeing how to change its log level/severity.
Here's (one branch of) the code I have now:
import os
from flask import request
from google.cloud import logging as gcp_logging
from google.cloud.logging.resource import Resource
client = gcp_logging.Client()
logger = client.logger('my_custom_log_type')
trace_id = (f"projects/{os.environ['GOOGLE_CLOUD_PROJECT']}/traces/"
f"{request.headers['X-Cloud-Trace-Context'].split('/')[0]}")
res = Resource(type='gae_app',
labels={'project_id': os.environ['GOOGLE_CLOUD_PROJECT'],
'module_id': os.environ['GAE_SERVICE'],
'version_id': os.environ['GAE_VERSION']})
logger.log_text('Sample log text', resource=res, trace=trace_id, severity='INFO')
It's working perfectly to group the logs with their requests, but the parent (request) log, e.g.,
> * 2019-11-19 15:54:56.613 EST GET 200 1.21 KiB 390ms Chrome 78 /
is displaying with the "Any" log level. I'd like it to be "Info" or "Error" as appropriate. How can I make this happen?