Skip to content

Latest commit

 

History

History
 
 

logging-manual

Cloud Run Manual Logging Sample

This sample shows how to send structured logs to Stackdriver Logging.

Run in Google Cloud

Build

docker build --tag logging-manual:python .

Run Locally

docker run --rm -p 9090:8080 -e PORT=8080 logging-manual:python

Test

pytest

Note: you may need to install pytest using pip install pytest.

Deploy

# Set an environment variable with your GCP Project ID
export GOOGLE_CLOUD_PROJECT=<PROJECT_ID>

# Submit a build using Google Cloud Build
gcloud builds submit --tag gcr.io/${GOOGLE_CLOUD_PROJECT}/logging-manual

# Deploy to Cloud Run
gcloud run deploy logging-manual \
--image gcr.io/${GOOGLE_CLOUD_PROJECT}/logging-manual \
--set-env-vars GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT}

Read more about Cloud Run logging in the Logging How-to Guide.

For more details on how to work with this sample read the Python Cloud Run Samples README