Skip to content

Logging

Daniel Dobalian edited this page Apr 17, 2018 · 2 revisions

MSAL allows apps to generate log messages that can help diagnose issues and provide details into what MSAL is doing. An app can configure logging with a few lines of code, and have custom control over the level of detail and whether or not Personal Identifiable Information (PII) or Organizational Identifiable Information (OII) is logged.

Enable Logging

private StringBuilder mLogs;

[...]

mLogs = new StringBuilder();
Logger.getInstance().setExternalLogger(new ILoggerCallback() {
   @Override
   public void log(String tag, Logger.LogLevel logLevel, String message, boolean containsPII) {
      mLogs.append(message).append('\n');
   }
});

Log Details

MSAL's logger allows for several levels of detail to be capture:

  • Error: Events that indicate something has gone wrong and an error was generated. Use for debugging and identifying problems.
  • Warning: Events that are of question and the app needs more information on. There hasn't necessarily been an error or failure, but intended for diagnostic and pinpointing problems.
  • Info: MSAL will log events intended for informational purposes not necessarily intended for debugging.
  • Verbose: Default. MSAL will log a large amount of information and give full details into what library behavior.

Identifiable Information (PII & OII)

By default, the MSAL logger will not capture any PII or OII.

To enable PII & OII,

Logger.getInstance().setEnablePII(true);

To disable PII & OII,

Logger.getInstance().setEnablePII(false);