Microsoft-identity-web: [Feature Request] Authentication logging

Created on 7 Dec 2020  路  10Comments  路  Source: AzureAD/microsoft-identity-web

Is logging available? If so, can you please point me to the documentation?

I'm looking for something like the WithLogging parameter for Microsoft Identity Client:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.identity.client.abstractapplicationbuilder-1.withlogging?view=azure-dotnet

Thanks

enhancement fixed needs documentation supportability

Most helpful comment

@jennyf19 I was just about to write you... works like a charm :)

Thanks again!

All 10 comments

@mtanml we integrate with the asp net core logs, which you can set up in the appsettings, more information here and more on configuring logging.

@jennyf19 thanks for the info! I was able to enable logging, but is there a way to limit the logs to authentication info? And I'm not seeing the level of detail that we get with Microsoft Identity Client (token acquisition/exchange, etc.) We use this info to troubleshoot user logins. Thanks!

@mtanml I understand. we do not hook up to the MSAL logs. So, yes, that would be a feature request.
cc: @jmprieur

@mtanml i have a branch w/ an initial commit to enable the MSAL .NET logs, but if you have suggestions or feedback on the developer experience, that would be much appreciated.

In appsettings.json, you would need to do the following in the AzureAD section:

 "EnableMsalPiiLogs": true, // set to false by default, so not necessary
 "LogLevel": "Info" //MSAL .NET includes "Info" "Warning" "Verbose" and "Error" logging options

I did the following to see the MSAL .NET logs in the console, but i'm sure you have something more interesting:

"Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information"
        },
        "Console": {
            "LogLevel": {
                "Default": "Information"
            }
        }

cc: @jmprieur

@jennyf19 I won't have time to do any testing soon, but I really appreciate the super-fast work on this! In our project that implements Microsoft.Identity.Client we use a method with the following parameters to capture authentication log info and write it to our database. As long as we'd be able to do the same in Microsoft.Identity.Web, then you have met our needs. Thanks a million!

private static void Log(Microsoft.Identity.Client.LogLevel level, string message, bool containsPii)

@mtanml we've changed a few things from the initial branch, so here is the info on logging in the wiki and we'll get this out in the next release. if you want to try it out, the changes have been merged to master.

Excellent, thank you @jennyf19 !

@mtanml we will get this in 1.4.1 release, which will probably be tomorrow (12.15)

@mtanml Included in 1.4.1 release

@jennyf19 I was just about to write you... works like a charm :)

Thanks again!

Was this page helpful?
0 / 5 - 0 ratings