Skip to content

Commit ddda2e3

Browse files
Santiago GonzalezSomkaPe
authored andcommitted
Update cache miss log level
1 parent 087b7c1 commit ddda2e3

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/main/java/com/microsoft/aad/msal4j/AuthenticationResultSupplier.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ public IAuthenticationResult get() {
8585
msalRequest.requestContext().correlationId(),
8686
error);
8787

88-
clientApplication.log.error(
89-
LogHelper.createMessage(
90-
"Execution of " + this.getClass() + " failed.",
91-
msalRequest.headers().getHeaderCorrelationIdValue()), ex);
92-
88+
logException(ex);
9389
throw new CompletionException(ex);
9490
}
9591
}
@@ -132,6 +128,22 @@ private void logResult(AuthenticationResult result, HttpHeaders headers) {
132128
}
133129
}
134130

131+
private void logException(Exception ex) {
132+
133+
String logMessage = LogHelper.createMessage("Execution of " + this.getClass()
134+
+ " failed.", msalRequest.headers().getHeaderCorrelationIdValue());
135+
136+
if (ex instanceof MsalClientException) {
137+
MsalClientException exception = (MsalClientException) ex;
138+
if (exception.errorCode().equalsIgnoreCase(AuthenticationErrorCode.CACHE_MISS)) {
139+
clientApplication.log.debug(logMessage, ex);
140+
return;
141+
}
142+
143+
clientApplication.log.error(logMessage, ex);
144+
}
145+
}
146+
135147
private ApiEvent initializeApiEvent(MsalRequest msalRequest){
136148
ApiEvent apiEvent = new ApiEvent(clientApplication.logPii());
137149
msalRequest.requestContext().telemetryRequestId(

0 commit comments

Comments
 (0)