Description
Environment details
-
OS type and version: Google Cloud Container Optimized OS (gke-12314-gke401-cos-93-16623-295-14-v221129-c-pre)
-
Python version: 3.8.10
-
pip version: 22.3.1
-
google-cloud-logging
version: 3.4.0
Steps to reproduce
- Either use werkzeug for serving or configure a werkzeug logger
- Setup a Google Cloud Logging Python client
- Log to the werkzeug logger and notice that logs are not sent to Google Cloud Logging.
Code example
import logging
import google.cloud.logging
logger = logging.getLogger('werkzeug')
client = google.cloud.logging.Client()
client.setup_logging()
logger.info('hello from werkzeug')
logging.info('hello from the root logger')
This results in hello from werkzeug
not being set to the global
log.
Due to EXCLUDED_LOGGER_DEFAULTS
werkzeug is excluded from the set of loggers that are sent to Google Cloud logging:
python-logging/google/cloud/logging_v2/handlers/handlers.py
Lines 27 to 33 in fceb6f3
google.cloud.logging.Client.setup_logging()
has an excluded_loggers
kwarg but setting that does not change the set of loggers that are ignored by the library due to the default set being added back into the set of ignored loggers in
The only workaround is to patch EXCLUDED_LOGGER_DEFAULTS
to remove werkzeug
from the list.