title | description | author | manager | ms.author | ms.custom | ms.date | ms.reviewer | ms.service | ms.topic |
---|---|---|---|---|---|---|---|---|---|
Logging errors and exceptions in MSAL for Android. |
Learn how to log errors and exceptions in MSAL for Android. |
henrymbuguakiarie |
CelesteDG |
henrymbugua |
devx-track-extended-java |
01/25/2021 |
saeeda, negoe |
identity-platform |
concept-article |
[!INCLUDE MSAL logging introduction]
Turn logging on at app creation by creating a logging callback. The callback takes these parameters:
tag
is a string passed to the callback by the library. It's associated with the log entry and can be used to sort logging messages.logLevel
enables you to decide which level of logging you want. The supported log levels are:Error
,Warning
,Info
, andVerbose
.message
is the content of the log entry.containsPII
specifies whether messages containing personal data, or organizational data are logged. By default, this is set to false, so that your application doesn't log personal data. IfcontainsPII
istrue
, this method will receive the messages twice: once with thecontainsPII
parameter set tofalse
and themessage
without personal data, and a second time with thecontainsPii
parameter set totrue
and the message might contain personal data. In some cases (when the message doesn't contain personal data), the message will be the same.
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');
}
});
By default, the MSAL logger won't not capture any personal identifiable information or organizational identifiable information. To enable the logging of personal identifiable information or organizational identifiable information:
Logger.getInstance().setEnablePII(true);
To disable logging personal data and organization data:
Logger.getInstance().setEnablePII(false);
By default logging to logcat is disabled. To enable:
Logger.getInstance().setEnableLogcatLog(true);
For more code samples, refer to Microsoft identity platform code samples.