azure-docs
azure-docs copied to clipboard
msal.js config file for logging does not work
[Enter feedback here]
Document Details
Besides the issue raised in https://github.com/MicrosoftDocs/azure-docs/issues/99854 There are also other places that need to change as well since the syntax used in that doc is for typescript and does not work in JS env. Below is the complete working config file (with Jason Nutter's help)
const msalConfig = { auth: { clientId: "xxx", // This is the ONLY mandatory field; everything else is optional. authority: b2cPolicies.authorities.signUpSignIn.authority, // Choose sign-up/sign-in user-flow as your default. knownAuthorities: [b2cPolicies.authorityDomain], // You must identify your tenant's domain as a known authority. redirectUri: "xxx", // You must register this URI on Azure Portal/App Registration. Defaults to "window.location.href". }, cache: { cacheLocation: "localStorage", // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO. storeAuthStateInCookie: false, // If you wish to store cache items in cookies as well as browser cache, set this to "true". }, system: { loggerOptions: { logLevel: msal.LogLevel.Verbose, loggerCallback: (level, message, containsPii) => { if (containsPii) { return; } switch (level) { case msal.LogLevel.Error: console.error(message); return; case msal.LogLevel.Info: console.info(message); return; case msal.LogLevel.Verbose: console.debug(message); return; case msal.LogLevel.Warning: console.warn(message); return; } }, piiLoggingEnabled: true }, }, };
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
- ID: 458301cb-79ae-0f32-8df3-c39ca6eabe2b
- Version Independent ID: 8ee3b8ee-2830-d72e-d743-07586def95cc
- Content: Logging errors and exceptions in MSAL.js - Microsoft Entra
- Content Source: articles/active-directory/develop/msal-logging-js.md
- Service: active-directory
- Sub-service: develop
- GitHub Login: @mmacy
- Microsoft Alias: marsma
@bachoang Thanks for your feedback! We will investigate and update as appropriate.
@bachoang Thanks for bringing this to our attention. I'm going to assign this to the document author so they can take a look at it accordingly
@Dickson-Mwendia Can you please check and add your comments on this doc update request as applicable.