For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
Fine-tuning with the Logger API
The MobileFirst client-side SDK makes internal use of the Logger API. By default, you are capturing log entries made by the SDK. To fine-tune log collection, use logger instances with package names. We can also control which logging level is captured by the analytics using server-side filters.
As an example to capture logs only where the level is ERROR for the myApp package name, follow these steps.
- iOS
- Use a logger instance with the myApp package name.
OCLogger *logger = [OCLogger getInstanceWithPackage:@"MyApp"];
Specify a filter to restrict log capture and log output to only the specified level and package programmatically. [OCLogger setFilters:@{@"MyApp": @(OCLogger_ERROR)}];
Optional: Control the filters remotely by following the steps in Fetching server configuration profiles. Android
- Use a logger instance with the myApp package name.
Logger logger = Logger.getInstance("MyApp");
- Specify a filter to restrict log capture and log output to only the specified level and package programmatically.
HashMap<String, LEVEL> filters = new HashMap<>(); filters.put("MyApp", LEVEL.ERROR); Logger.setFilters(filters);
- Optional: Control the filters remotely by following the steps in Fetching server configuration profiles.
JavaScript (Cordova)
- Use a logger instance with the myApp package name.
var logger = WL.Logger.create({ pkg: 'MyApp' });
- Optional: Specify a filter to restrict log capture and log output to only the specified level and package programmatically.
WL.Logger.config({ filters: { 'MyApp': 'ERROR' } });
- Optional: Control the filters remotely by following the steps in Fetching server configuration profiles.
web For the web SDK the level cannot be set by the client. All logging is sent to the server until the client retrieves the server profile.
Parent topic: Logger SDK