Logging in native Android (Java)

improve this page | report issue

Android MobileFirst Platform SDK cannot persistently capture log data until the com.worklight.common.Logger.setContext(Context) method is called.

Logging example for native Android (Java):

Outputs to LogCat:

import com.worklight.common.Logger;
public class MathUtils{
  private static final Logger logger = Logger.getInstance(MathUtils.class.getName());
  public int sum(final int a, final int b){
  int sum = a + b;
  logger.debug("sum called with args " + a + " and " + b + ". Returning " + sum);
  return sum;
  }
}

API calls for specific tasks

Turn log capture on or off:

Logger.setCapture(boolean)

Control capture level (verbosity):

Logger.setLevel(LEVEL)

Turn automatic log sending on or off:

Logger.setAutoSendLogs(boolean)

Turn automatic configuration retrieval on or off:

Logger.setAutoUpdateConfig(boolean)

Last modified on November 09, 2016