From 1f8ad7152f0d6f80f2738d57c89fc35bc3e47d92 Mon Sep 17 00:00:00 2001 From: Sean Lip Date: Sat, 23 Nov 2024 04:15:11 +0800 Subject: [PATCH] Suppress unnecessary gunicorn and grpc logs. (#21290) --- app_dev.yaml | 9 +++++++-- app_dev_docker.yaml | 9 +++++++-- main.py | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app_dev.yaml b/app_dev.yaml index 9d329d610393..4f9e60fc0d2a 100644 --- a/app_dev.yaml +++ b/app_dev.yaml @@ -4,8 +4,9 @@ instance_class: F2 # #6534 on oppia/oppia). version: default # Timeout is set to 60 so that the gunicorn workers don't die while sending -# the Apache Beam jobs to Google Cloud Dataflow. -entrypoint: gunicorn --timeout 60 --bind :$PORT main:app +# the Apache Beam jobs to Google Cloud Dataflow. Log level is set to 'warning' +# because the info logs are very noisy. +entrypoint: gunicorn --timeout 60 --log-level warning --bind :$PORT main:app inbound_services: - warmup @@ -181,3 +182,7 @@ env_variables: DATASTORE_PROJECT_ID: "dev-project-id" DATASTORE_USE_PROJECT_ID_AS_APP_ID: "true" SECRETS: "{\"ANDROID_BUILD_SECRET\": \"android-build-secret\", \"VM_ID\": \"vm_default\", \"SHARED_SECRET_KEY\": \"1a2b3c4e\"}" +# These environment variables control GRPC logging verbosity. See +# https://stackoverflow.com/a/78803598. + GRPC_VERBOSITY: "ERROR" + GLOG_minloglevel: "2" diff --git a/app_dev_docker.yaml b/app_dev_docker.yaml index 55dc92c3b9c0..681b4c61710f 100644 --- a/app_dev_docker.yaml +++ b/app_dev_docker.yaml @@ -6,8 +6,9 @@ instance_class: F2 # #6534 on oppia/oppia). version: default # Timeout is set to 60 so that the gunicorn workers don't die while sending -# the Apache Beam jobs to Google Cloud Dataflow. -entrypoint: gunicorn --timeout 60 --bind :$PORT main:app +# the Apache Beam jobs to Google Cloud Dataflow. Log level is set to 'warning' +# because the info logs are very noisy. +entrypoint: gunicorn --timeout 60 --log-level warning --bind :$PORT main:app inbound_services: - warmup @@ -188,3 +189,7 @@ env_variables: DATASTORE_PROJECT_ID: "dev-project-id" DATASTORE_USE_PROJECT_ID_AS_APP_ID: "true" SECRETS: "{\"ANDROID_BUILD_SECRET\": \"android-build-secret\", \"VM_ID\": \"vm_default\", \"SHARED_SECRET_KEY\": \"1a2b3c4e\"}" +# These environment variables control GRPC logging verbosity. See +# https://stackoverflow.com/a/78803598. + GRPC_VERBOSITY: "ERROR" + GLOG_minloglevel: "2" diff --git a/main.py b/main.py index 93c4f0bdf23b..9e8c36fdf2b2 100644 --- a/main.py +++ b/main.py @@ -101,7 +101,7 @@ # Cloud Logging is disabled in emulator mode, since it is unnecessary and # creates a lot of noise. if not constants.EMULATOR_MODE: - # Instantiates a client and rtrieves a Cloud Logging handler based on the + # Instantiates a client and retrieves a Cloud Logging handler based on the # environment you're running in and integrates the handler with the Python # logging module. client = google.cloud.logging.Client()