Kubernetes Blog

Contextual logging in Kubernetes 1.29: Better troubleshooting and enhanced logging

Follow
Contextual logging, a feature introduced in Kubernetes v1.24, has been migrated to kube-scheduler and kube-controller-manager to provide more useful logs for troubleshooting. Based on the go-logr API, it allows libraries to pass a logger instance for logging instead of accessing a global logger, with the binary deciding the logging implementation. This enables additional use cases such as attaching additional information to a logger and associating log output with the current test, making it easier to identify and debug issues. To use contextual logging, enable the ContextualLogging feature gate on the kube-controller-manager and kube-scheduler. Carefully consider using WithName and WithValues for performance reasons, especially at debug levels. Log output may change regularly due to ongoing conversion to structured and contextual logging, so downstream users should be aware of these changes. Contributors are welcome to join the Structured Logging WG to participate in its development.
favicon
kubernetes.io
kubernetes.io
Create attached notes ...