I tried to log my message to google clog logs using the standard gcloud logs library code. It is throwoing an error message - "ImportError: cannot import name 'logging' from 'google.cloud' (unknown location)". Please advise where I am doing wrong?
# Imports the Google Cloud client library
from google.cloud import logging
# Instantiates a client
logging_client = logging.Client()
# The name of the log to write to
log_name = "EN-LOG"
# Selects the log to write to
logger = logging_client.logger(log_name)
# The data to log
text = "My test message"
# Writes the log entry
logger.log_text(text)
I am expecting the log to be listed in the google clod logs explorer under the log name specified in the script "EN-LOG". But it throwing an error when I try to run the script. "ImportError: cannot import name 'logging' from 'google.cloud' (unknown location)". Please advise where I am doing wrong?
maybe try "import google.cloud.logging"