I am trying to write logs while using python on google app engine flexible environment.
I want to use the default python logging library and use a handler for logging. This is my code:
import logging
import google.cloud.logging # Don't conflict with standard logging
from google.cloud.logging.handlers import CloudLoggingHandler,setup_logging
client = google.cloud.logging.Client(app.config['PROJECT_ID'])
handler = CloudLoggingHandler(client)
# Attaches the handler to the root logger
setup_logging(handler)
logging.info("blabla")
It just doesn't work, I can't find the logs in stackdriver logging. I tryed writing the logs without an handler like this:
from google.cloud import logging
client = logging.Client()
logger = client.logger('log_name')
logger.log_text("blabla")
Also, doesn't work.
I also tryed to write the logs to stdout but I don't have the option to select it in stackdriver logging.
Everything worked fine when I used the standard environment..