Remote Logger

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.

Copied#import <Apptics/Apptics.h>
Copiedimport 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:<#(BOOL)#>];
  [APLog setLogLevel:<#(APLogLevel)#>]
  return true;
}
Copiedfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {  
    Apptics.initialize(withVerbose: <#T##Bool#>)
    APLog.setLogLevel(<#T##APLogLevel#>)
    return true
}

We have also included the option to enable/disable the logger from the analytics settings screen.

Enable/disable remote logger

Copied[APLog setLogStatus:<#(BOOL)#>]
CopiedAPLog.setLogStatus(<#T##status: Bool##Bool#>)
  • To get the current status of the remote logger, use the below.
Copied[APLog logStatus];
CopiedAPLog.logStatus()

Track logs

  • Use the APLog similar to the NSLog / Print functions to track and send logs to Apptics.
CopiedAPLogVerbose(@"Verbose");
APLogDebug(@"Debug");
APLogInfo(@"Info");
APLogWarn(@"Warn");
APLogError(@"Error");
CopiedAPLogVerbose("Verbose")  
APLogDebug("Debug")
APLogInfo("Info")
APLogWarn("Warn")
APLogError("Error")
  • Logs will be printed to the console only if Apptics is initialized with verbose true in your app launch.
CopiedApptics.initialize(withVerbose: true)

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 4 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]);
CopiedAPLogDebug("Debug \(("xyz@email.com" as NSString).ap_privacy(.privateMask))")
APLogWarn("Warn \(("xyz@email.com" as NSString).ap_privacy(.private))")
APLogError("Error \(("xyz@email.com" as NSString).ap_privacy(.sensitive))")
APLogInfo("Info \(("xyz@email.com" as NSString).ap_privacy(.sensitiveMask))")

The Xcode console and the Console.app will show the data as normal when a debugger is attached. However, opening the app while no debugger is attached will show the following output in the Console.app and Apptics web.

The email is logged as or or <encrypted base64 string==> instead which prevents your data from being readable by anyone inside the logs.

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.