Skip to content

Logging

kreedula edited this page Apr 19, 2018 · 4 revisions

Logs

ADAL allows apps to generate log messages that can help diagnose issues. You configure logging by making the following call to configure a callback that ADAL will use to hand off each log message as it is generated.

Logger.getInstance().setExternalLogger(new ILogger() {
    @Override
    public void Log(String tag, String message, String additionalMessage, LogLevel level, ADALError errorCode) {
     ...
     // You can write this to logfile depending on level or errorcode.
     Log.d(TAG, message + " " + additionalMessage);
    }
}

Personal Identifiable Information (PII) & Organizational Identifiable Information (OII)

By default, ADAL telemetry does not capture or log any PII or OII. The library allows app developers to turn this on through a setter in the Logger class. By turning on PII or OII, the app takes responsibility for safely handling highly-sensitive data and complying with any regulatory requirements.

// By default, the `Logger` does not capture any PII or OII

// PII or OII will be logged
Logger.getInstance().setEnablePII(true);

// PII or OII will NOT be logged
Logger.getInstance().setEnablePII(false);
Logging Levels
  • Error(Exceptions)
  • Warn(Warning)
  • Info(Information purposes)
  • Verbose(More details)

You set the log level like this: Logger.getInstance().setLogLevel(Logger.LogLevel.Verbose);

All log messages are sent to logcat in addition to any custom log callbacks. You can get log to a file form logcat as shown below: adb logcat > "C:\logmsg\logfile.txt"

More examples about adb cmds: https://developer.android.com/tools/debugging/debugging-log.html#startingLogcat

Clone this wiki locally