Fix Include stack trace in token error logs#47974
Merged
g2vinay merged 1 commit intoAzure:mainfrom Feb 11, 2026
Merged
Conversation
This change modifies LoggingUtil.logTokenError to pass the Throwable exception to the logger, ensuring that stack traces (including inner exceptions) are logged along with the error message. Previously, only the error message was logged, making it difficult to diagnose issues when errors referenced 'inner exceptions' that were not visible in the logs. The fix aligns the logging behavior with logCredentialUnavailableException, which already properly logs stack traces. Fixes #<issue-number>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Azure Identity token acquisition error logging by ensuring LoggingUtil.logTokenError passes the thrown Throwable to ClientLogger, so stack traces (including nested/inner exceptions) are emitted in logs, addressing diagnostics gaps reported in #47155.
Changes:
- Update
LoggingUtil.logTokenErrorto log with theThrowableso stack traces are included. - Add unit tests for
LoggingUtil(currently focused on non-throwing behavior).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
sdk/identity/azure-identity/src/main/java/com/azure/identity/implementation/util/LoggingUtil.java |
Passes the exception into the logger call to include stack traces for token errors. |
sdk/identity/azure-identity/src/test/java/com/azure/identity/implementation/util/LoggingUtilTest.java |
Adds tests for LoggingUtil methods (but does not yet assert stack trace logging). |
...ity/azure-identity/src/test/java/com/azure/identity/implementation/util/LoggingUtilTest.java
Show resolved
Hide resolved
...dentity/azure-identity/src/main/java/com/azure/identity/implementation/util/LoggingUtil.java
Show resolved
Hide resolved
anannya03
approved these changes
Feb 11, 2026
1b65dbc to
58323cf
Compare
anannya03
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #47155
This change modifies LoggingUtil.logTokenError to pass the Throwable exception to the logger, ensuring that stack traces (including inner exceptions) are logged along with the error message.
Previously, only the error message was logged, making it difficult to diagnose issues when errors referenced 'inner exceptions' that were not visible in the logs.
The fix aligns the logging behavior with logCredentialUnavailableException, which already properly logs stack traces.