-
Notifications
You must be signed in to change notification settings - Fork 25
Setting up remote logging with Logentries
For easier diagnostics and troubleshooting once your app is "out in the wild" (running on users' devices), you can use remote logging with Logentries. To do this, perform the following 3 steps:
1) Set the configuration parameter tracking
to true
2) Change index-template.html
file (https://github.com/leob/ionic-quickstarter/blob/master/src/index-template.html) to activate Logentries initialization and to set your Logentries Token
3) Modify the Tracking service (https://github.com/leob/ionic-quickstarter/blob/master/src/js/app/util/services/tracking.service.js) to activate the "Logentries" implementation of the Tracking service, instead of the "Dummy" implementation of the Tracking service
ad 1) Setting the configuration parameter tracking
to true
The app can run in 2 different "modes": "dev" (development mode) and "prod" (production mode).
Now, normally you would use remote logging (with Logentries) ONLY in "production" mode (when the app runs on a user's device), because you will want to know what is going on on the user's device (especially if there is a problem).
In "development" mode (when you are running the app in a browser with "ionic run") there is no need for remote logging (Logentries) because you can just look at the local console.
This is the reason why "tracking" is set to "false" in the "dev" configuration file (config-dev.json) but to "true" in the "prod" configuration file (config-prod.json).
So, in https://github.com/leob/ionic-quickstarter/blob/master/src/js/config/config-dev.json it looks like this:
...
"tracking": false
...
while in https://github.com/leob/ionic-quickstarter/blob/master/src/js/config/config-prod.json is looks like this:
...
"tracking": true
...
So in "prod" mode the "tracking" parameter is already set (which means that potentially Logentries can be used), while in "dev" mode "tracking" is set to "false" (which means, no Logentries).
If you want "remote" logging (with Logentries) for "dev" mode as well, set the "tracking" parameter to true in config-dev.json
.
ad 2) Changing index-template.html
In the index-template.html
file, you will see these 4 lines:
<!--<script src="js/lib/logentries/le.min.js"></script>-->
<!--<script>-->
<!--LE.init({token: 'PASTE-YOUR-LOGENTRIES-TOKEN-HERE', print: false});-->
<!--</script>-->
You must uncomment these lines, like this:
<script src="js/lib/logentries/le.min.js"></script>
<script>
LE.init({token: 'PASTE-YOUR-LOGENTRIES-TOKEN-HERE', print: false});
</script>
Next, you must replace 'PASTE-YOUR-LOGENTRIES-TOKEN-HERE' with your Logentries token, for instance it will look like this (note that the token value below is fake, you need to put the real token value from your Logentries dashboard here):
LE.init({token: 'xbfbu3j3-1zkp-h54a-8wv7-78a762x823rs', print: false});
ad 3) Modifying the Tracking service
In the tracking.service.js
file, you will see these lines:
//if (APP.devMode) {
return $injector.get('TrackingServiceDummyImpl');
//} else {
// return $injector.get('TrackingServiceLogentriesImpl');
//}
To use Logentries (in production mode), you need to change these lines as follows:
if (APP.devMode) {
return $injector.get('TrackingServiceDummyImpl');
} else {
return $injector.get('TrackingServiceLogentriesImpl');
}
If you want Logentries in "development" mode too, change it as follows:
if (APP.devMode) {
return $injector.get('TrackingServiceLogentriesImpl');
} else {
return $injector.get('TrackingServiceLogentriesImpl');
}
or simply:
return $injector.get('TrackingServiceLogentriesImpl');
That's all, with these 3 steps you should have remote logging with Logentries.