Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

werkzeug logs are filtered out by default #713

Closed
stewartmiles opened this issue Jan 24, 2023 · 0 comments · Fixed by #831
Closed

werkzeug logs are filtered out by default #713

stewartmiles opened this issue Jan 24, 2023 · 0 comments · Fixed by #831
Labels
api: logging Issues related to the googleapis/python-logging API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@stewartmiles
Copy link

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

  1. Either use werkzeug for serving or configure a werkzeug logger
  2. Setup a Google Cloud Logging Python client
  3. 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:

"""Exclude internal logs from propagating through handlers"""
EXCLUDED_LOGGER_DEFAULTS = (
"google.cloud",
"google.auth",
"google_auth_httplib2",
"google.api_core.bidi",
"werkzeug",

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

all_excluded_loggers = set(excluded_loggers + EXCLUDED_LOGGER_DEFAULTS)

The only workaround is to patch EXCLUDED_LOGGER_DEFAULTS to remove werkzeug from the list.

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/python-logging API. label Jan 24, 2023
@losalex losalex assigned daniel-sanche and unassigned losalex Jan 25, 2023
@losalex losalex added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 25, 2023
@daniel-sanche daniel-sanche added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jun 13, 2023
@daniel-sanche daniel-sanche removed their assignment Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/python-logging API. priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
3 participants