Skip to content

Fix Include stack trace in token error logs#47974

Merged
g2vinay merged 1 commit intoAzure:mainfrom
g2vinay:fix-identity-logging-stack-trace
Feb 11, 2026
Merged

Fix Include stack trace in token error logs#47974
g2vinay merged 1 commit intoAzure:mainfrom
g2vinay:fix-identity-logging-stack-trace

Conversation

@g2vinay
Copy link
Member

@g2vinay g2vinay commented Feb 10, 2026

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.

@g2vinay g2vinay changed the title Fix: Include stack trace in token error logs Fix Include stack trace in token error logs Feb 10, 2026
@g2vinay g2vinay marked this pull request as ready for review February 11, 2026 00:05
@g2vinay g2vinay requested review from a team and joshfree as code owners February 11, 2026 00:05
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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.logTokenError to log with the Throwable so 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).

@g2vinay g2vinay force-pushed the fix-identity-logging-stack-trace branch from 1b65dbc to 58323cf Compare February 11, 2026 00:22
@g2vinay g2vinay merged commit a68049c into Azure:main Feb 11, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

[BUG] [azure-identity] Stacktrace not logged on error in getToken() call

2 participants