I am using azure-identity to authenticate and microsoft-graph apis to fetch data from Microsoft Teams. Somehow azure-identity APIs are logging too much unwanted logs, those repetitive and not much of having important information, just like below.
2022-12-19 20:51:05.256 INFO 28050 --- [ol-1-worker-105] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.256 INFO 28050 --- [ool-1-worker-69] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.256 INFO 28050 --- [ool-1-worker-69] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.256 INFO 28050 --- [ol-1-worker-105] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.357 INFO 28050 --- [onPool-worker-5] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.358 INFO 28050 --- [onPool-worker-5] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.387 INFO 28050 --- [Pool-1-worker-3] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.387 INFO 28050 --- [Pool-1-worker-3] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.513 INFO 28050 --- [ool-1-worker-59] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.513 INFO 28050 --- [ool-1-worker-59] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.566 INFO 28050 --- [ool-1-worker-69] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.566 INFO 28050 --- [ool-1-worker-69] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.614 INFO 28050 --- [onPool-worker-5] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.614 INFO 28050 --- [onPool-worker-5] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.662 INFO 28050 --- [ool-1-worker-21] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.663 INFO 28050 --- [ool-1-worker-21] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
2022-12-19 20:51:05.678 INFO 28050 --- [ol-1-worker-103] c.m.a.msal4j.AcquireTokenSilentSupplier : Returning token from cache
2022-12-19 20:51:05.678 INFO 28050 --- [ol-1-worker-103] c.azure.identity.ClientSecretCredential : Azure Identity => getToken() result for scopes [ https://graph.microsoft.com/.default]: SUCCESS
My pom.xml entry for azure-identity and microsoft-graph is as below.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.6.1</version>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>5.17.0</version>
</dependency>
My Question is, is there any way to stop those logs, is there any way to control it?
Found this as I am looking for the same solution.
Looks like Microsoft requires an extra hoop to jump through to control the logging level of the MSAL library.
For Java: This involves creating a logging XML file and pointing to it with a System.properties setting. Setting the level to "error" or "warn" should stop these messages. https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-logging-java
If your solution is not using Java, see this link for other implementations https://learn.microsoft.com/en-us/azure/active-directory/develop/msal-client-application-configuration#logging
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.