-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
api: loggingIssues related to the googleapis/python-logging API.Issues related to the googleapis/python-logging API.
Description
We want to modify the timestamp of a specific log entry to backdate it to the time when the http request was received instead of when the log gets actually written, as this seems to be the way http access logs should be formatted.
However, we were unable to do so via python's stdlib logging interface. We tried setting the timestamp via the extra field as described in the docs, but this had no effect.
Can you give us a quick example how to modify the timestamp of a single log entry while using the stdlib logging interface? It seems to be possible to simply set the timestamp directly when logging via log_struct as described in #542, but we'd like to keep using the python stdlib's logging interface.
Environment details
- OS type and version: Cloud Run, container image
ubuntu-minimal-2404-lts-amd64 - Python version: Python 3.12.12
- pip version: pip 25.0.1
google-cloud-loggingversion: 3.11.2
Code example
logging.info("hello", extra={"timestamp": timestamp})Metadata
Metadata
Assignees
Labels
api: loggingIssues related to the googleapis/python-logging API.Issues related to the googleapis/python-logging API.