MSAL logging improvements
Discussed in https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/discussions/3010
Originally posted by bgavrilMS November 12, 2021 Suggested improvements that can be made to MSAL logging:
Common log interface for MSAL/SAL/Wilson/MISE
- [x] https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3245
Apps should not have to recompile to get verbose logs
- [x] Allow apps to change the logging verbosity based on an env variable (this will require a process restart)
- [ ] Allow apps to change logging verbosity programmatically #2868
- [ ] Allow apps to collect event logs, even if a logging callback has not been enabled (WithLogging + enable default logger already uses event source, but it's not turned on by default).
Better logging in token caches
- [ ] Microsoft.Identity.TokenCache should reuse MSAL's logger
- [ ] The desktop cache should reuse MSAL's logger
- [x] Expose the correlation ID to token cache implementations #3008
Logging perf
- [ ] Logging should not compute log strings unless the log level is met.
Add more info in the logs
- [x] #2029
- [x] Log important metrics irrespective of the log level #3004
Additional discussion around logging: #1993
This quarter we want to do only:
- token cache logic uses MSAL loggers
- allow apps to change log level dynamically (i.e.
.WithLogging(Func<LogLevel>, ...))
@bgavrilMS dynamically? you mean on AcquireTokenXXBuilder?
no, I mean:
private static LogLevel _logLevel = LogLevel.Warning;
private IConfidentialClientApplicaiton CreateCCA()
{
var cca = ConfidentialClientApplicationBuidler.Create(id).
.WithLogging(
() =>_logLevel ,
LogCallback);
}
// apps monitor config or env changes
private void OnConfigChange()
{
_logLevel = // read log level from config
}
updating details with https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3245
This has not been completed.
@bgavrilMS yeah, not sure how this got closed. Must a bug somewhere.
Tracking item for logging improvements.
T