Remote logger for Cocoa apps
Remote logger helps you to get the applications logs without asking the users. Remote Logger will be installed along with Apptics by default.
Before you begin, ensure that Apptics is integrated into your project by following the Integration Guide.
You can simply import Apptics. If you have installed Apptics using any of our mediums, you will have to call the below lines after initializing Apptics.
Enable/Disable remote logger
- By default remote logging is disabled, to enable/disable the logger set the log level ranging from all to off.
Note: Remote Logger will be automatically turned off if usage tracking is disabled.
Copied- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {
[Apptics initializeWithVerbose:YES];
[APLog setLogLevel:APLogLevelAll];
return YES;
}
Copiedfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Apptics.initialize(withVerbose: true)
APLog.setLogLevel(.all)
return true
}
We have also included the option to enable/disable the logger from the analytics settings screen.
Enable/disable remote logger from settings screen
Check logger status
- To get the current status of the logger, use the following.
Track logs
- Use the APLog similar to the NSLog / Print functions to track and send logs to Apptics.
CopiedAPLogVerbose(@"Verbose log");
APLogDebug(@"Debug log");
APLogInfo(@"Info log");
APLogWarn(@"Warn log");
APLogError(@"Error log");
- Logs will be printed to the console only if Apptics is initialized with verbose true in your app launch.
Mask sensitive information
You can mask the sensitive/private data using our string extension methods. In the below examples, we’re logging the email in various ways to show the differences.
CopiedAPLogDebug(@"Debug %@", [@"xyz@email.com" ap_privacy:APLogPrivacyPrivateMask]);
APLogWarn(@"Warn %@", [@"xyz@email.com" ap_privacy:APLogPrivacyPrivate]);
APLogError(@"Error %@", [@"xyz@email.com" ap_privacy:APLogPrivacySensitive]);
APLogInfo(@"Info %@", [@"xyz@email.com" ap_privacy:APLogPrivacySensitiveMask]);
CopiedAPLog.debug("Debug \( "xyz@email.com".ap_privacy(.privateMask))")
APLog.warn("Warn \( "xyz@email.com".ap_privacy(.private))")
APLog.error("Error \( "xyz@email.com".ap_privacy(.sensitive))")
APLog.info("Info \( "xyz@email.com".ap_privacy(.sensitiveMask))")
When no debugger is attached, these logs will show as <encrypted base64 string> in the console and Apptics, ensuring sensitive data is protected.
How does Apptics logger works?
Apptics Logger writes the logs added by the developer in a file stored in the app's cache directory. Stored log files are then uploaded to the server upon the next app cold start or whenever the data reaches the defined threshold.
Max offline limit of log files is set to 2MB and each log file is limited to 450kb. If the log storage exceeds the allocation, the oldest log file will be deleted to store the recent logs.