We are working on migrating our AppEngine Python 2.7 code to 3.11. When we try to use the logging.info call, we cannot see the respective message on the terminal window. Following is the command used to start the server:
python3 ../../google-cloud-sdk/bin/dev_appserver.py --runtime_python_path="python27=/Library/Frameworks/Python.framework/Versions/2.7/bin/python,python3=/opt/homebrew/bin/python3" --datastore_path=../datastore_local_3 --storage_path=../storage --require_indexes=yes --port=8080 --admin_port=8000 --support_datastore_emulator=False --application=my-app --dev_appserver_log_level=info --log_level=info --logs_path=../logs app.yaml
The following code is called in the main.py of the Flask app.
import google.cloud.logging
client = google.cloud.logging.Client()
client.setup_logging()
import logging
logging.debug("This is a debug message")
logging.info("This is an info message")
logging.warning("This is a warning message")
logging.error("This is an error message")
logging.critical("This is a critical message")
Please let me know what might be the issue here.
I got it to work by running the following commands:
gcloud auth login
gcloud auth application-default login