If you are using SP 13 or higher please see Logger SP13+
The easiest way to log a message in a Kapsel app that is being run on a device or emulator attached to an Android IDE or Xcode, is to simply use the log method.
console.log("Log this");
This method works in Kapsel apps and in apps being debugged on the desktop using Chrome.
Note that in an iOS Cordova app, it requires adding the console plugin, the import of cordova.js, and will only work after the deviceready event is fired. These restrictions are not present on Android.
The console plugin can be added with the cordova plugin add command.
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
Note that the console plugin appears to log messages twice on Android CB-1973.
A log tag filter can be applied to only show messages logged from chromium by editing the message filter named com.mycompany.logger.
Note, in the Eclipse LogCat view, it is possible to exclude certain tags from the view by entering a regular expression such as
tag:^(?!(AndroidRuntime|linker|memtrack|dalvikvm|android.os.Debug|jdwp|SoundPool|AudioService|eglCodecCommon))
If using an Android device or simulator, the Android log file can be retrieved from the device using
adb logcat > C:\temp\log.txt
On iOS simulators and devices, the output from console.log can be seen in the All Output view.
On iOS devices, the console log can also be viewed by connecting the device to a Mac and in Xcode choosing Window > Organizer > Device > Console as shown below. Note that the console log file does not stay on the device for very long.
The Kapsel logger plugin enables messages to be logged at one of four levels (Debug, Info, Warn or Error) using
sap.Logger.debug("Message to be logged at DEBUG level");
sap.Logger.info("Message to be logged at INFO level");
sap.Logger.warn("Message to be logged at WARN level");
sap.Logger.error("Message to be logged at ERROR level");
It also provides a method,
sap.Logger.upload()
that when called can upload the log to the SMP 3.0 server.
The default log level is ERROR. If the log level is set to WARN, then messages logged at WARN or ERROR would appear in the log.
The log level is set by calling
sap.Logger.setLogLevel(sap.Logger.DEBUG);
Note, this is a transient setting on iOS and is in effect as long as the application remains in memory.
In addition to the above methods, the Kapsel Logger as of SP05 captures the output of console.log and includes it in the log that can be uploaded to the SMP 3.0 server. When the Kapsel Logger plugin is included, there is no need for the console plugin so it can be removed by running the below command.
cordova remove org.apache.cordova.console
The console.log entries appear on Android three times one of which is with the log tag of SMP_LOGGER. The logged entry SMP_LOGGER only appears if the Logger plugin's log level is set to be INFO or DEBUG. For additional details see the JavaScript file in a project that includes this plugin at
project_name\www\plugins\com.sap.mp.cordova.plugins.logger\www\logger.js
or the JS Documentation at Kapsel Logger API Reference.
The following steps will demonstrate this plugin.
com.mycompany.logger
This app does not use an OData endpoint so that can be set to a dummy URL such ashttp://mycompany.com
and add the Basic SSO mechanism.cordova -d create C:\Kapsel_Projects\LoggerDemo com.mycompany.logger LoggerDemo "{\"plugin_search_path\":\"C:/SAP/MobileSDK3/KapselSDK/plugins/\"}"
cd LoggerDemo
cordova -d platform add android
cordova -d create ~/Documents/Kapsel_Projects/LoggerDemo com.mycompany.logger LoggerDemo "{\"plugin_search_path\":\"/Users/i826567/SAP/MobileSDK3/KapselSDK/plugins/\"}"
cd ~/Documents/Kapsel_Projects/LoggerDemo
cordova -d platform add ios
cordova -d plugin add com.sap.mp.cordova.plugins.logger
cordova -d prepare
C:\Kapsel_Projects\LoggerDemo\platforms\android\assets\sap-supportability.properties
clientLogManager=com.sap.smp.client.supportability.log.ClientLogManagerImpl
e2eTraceManager=com.sap.smp.client.supportability.e2e.E2ETraceManagerImpl
file_size=102400
file_count=10
file_age=604800000
The file_age is in milliseconds. The default shown above is 7 days. After seven days, the logs are erased.
Back to Getting Started With Kapsel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |