For up-to-date product documentation, see the IBM MobileFirst Foundation Developer Center.
Sending captured logs
Send logs to the server according to our application's logic. Auto log send can also be enabled to automatically send logs. If logs are not sent before the maximum size is reached, the log file is then purged in favor of newer logs.
Before you begin
- Ensure that you enabled log capture. For more information, see Enabling log capture.
- Ensure that the verbosity of logs that we want to see in the MobileFirst Analytics Console matches the verbosity that is set on the client. See Set Log Filters from the MobileFirst Operations Console.
As an example to send logs on a 1-minute interval timer, follow these steps.
Note: Adopt the following pattern when you collect log data. Sending data on an interval ensures that you are seeing your log data in near real-time in the MobileFirst Analytics Console.
- iOS
[NSTimer scheduledTimerWithTimeInterval:60 target:[OCLogger class] selector:@selector(send) userInfo:nil repeats:YES];
Android Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { Logger.send(); } }, 0, 60000);
JavaScript (Cordova) setInterval(function() { WL.Logger.send(); }, 60000);
Web setInterval(function() { ibmmfpfanalytics.logger.send(); }, 60000);
To ensure that all captured logs are sent, consider one of the following strategies:
- Call the send method at a time interval.
- Call the send method from within the app lifecycle event callbacks.
- Increase the max file size of the persistent log buffer (in bytes):
- iOS
[OCLogger setMaxFileSize:150000];
- Android
Logger.setMaxFileSize(150000);
JavaScript WL.Logger.config({ maxFileSize: 150000 });
web The maximum file size for the web API is 5 mb and cannot be changed.
Parent topic: Logger SDK