microsoft-authentication-library-for-dotnet icon indicating copy to clipboard operation
microsoft-authentication-library-for-dotnet copied to clipboard

MSAL logging improvements

Open bgavrilMS opened this issue 4 years ago • 7 comments

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

bgavrilMS avatar Nov 18 '21 12:11 bgavrilMS

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 avatar Jan 27 '22 19:01 bgavrilMS

@bgavrilMS dynamically? you mean on AcquireTokenXXBuilder?

jmprieur avatar Jan 27 '22 19:01 jmprieur

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
}



bgavrilMS avatar Jan 28 '22 14:01 bgavrilMS

updating details with https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/3245

trwalke avatar Mar 23 '22 18:03 trwalke

This has not been completed.

bgavrilMS avatar Jul 21 '22 14:07 bgavrilMS

@bgavrilMS yeah, not sure how this got closed. Must a bug somewhere.

trwalke avatar Jul 21 '22 15:07 trwalke

Tracking item for logging improvements.

bgavrilMS avatar Jul 26 '22 12:07 bgavrilMS

T

bgavrilMS avatar Oct 12 '22 17:10 bgavrilMS