ReadonlyORDER_Sort ascending when querying logs. Mirrors Logger.ORDER_ASC constant.
ReadonlyORDER_Sort descending when querying logs. Mirrors Logger.ORDER_DESC constant.
Returns the records from log database as a String. Provide an optional SQLQuery to contrain results between dates.
Depending on the configured LoggerConfig.logLevel, the plugin can store an immense amount of helpful logging information for debugging location-tracking problems.
âšī¸ See also:
3 days)Optionalquery: SQLQueryBackgroundGeolocation.logger.getLog().then((log) => {
// Warning: this string could be several megabytes.
console.log("[log] success: ", log);
});
// Or constrain results by providing a SQLQuery
let Logger = BackgroundGeolocation.logger;
let log = await Logger.getLog({
start: Date.parse("2019-09-19 11:12"),
end: Date.parse("2019-09-19 11:13"),
order: Logger.ORDER_ASC,
limit: 100
});
09-19 11:12:18.716 ââââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:18.716 â BackgroundGeolocation Service started
09-19 11:12:18.716 â âââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:18.723 [c.t.l.BackgroundGeolocationService d]
09-19 11:12:18.723 â
Started in foreground
09-19 11:12:18.737 [c.t.l.ActivityRecognitionService a]
09-19 11:12:18.737 đž Start activity updates: 10000
09-19 11:12:18.761 [c.t.l.BackgroundGeolocationService k]
09-19 11:12:18.761 đ´ Stop heartbeat
09-19 11:12:18.768 [c.t.l.BackgroundGeolocationService a]
09-19 11:12:18.768 đž Start heartbeat (60)
09-19 11:12:18.778 [c.t.l.BackgroundGeolocationService a]
09-19 11:12:18.778 đĩ setPace: null â false
09-19 11:12:18.781 [c.t.l.adapter.TSConfig c] âšī¸ Persist config
09-19 11:12:18.794 [c.t.locationmanager.util.b a]
09-19 11:12:18.794 âšī¸ LocationAuthorization: Permission granted
09-19 11:12:18.842 [c.t.l.http.HttpService flush]
09-19 11:12:18.842 ââââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:18.842 â HTTP Service
09-19 11:12:18.842 â âââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:19.000 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
09-19 11:12:21.314 [c.t.l.l.SingleLocationRequest$2 onLocationResult]
09-19 11:12:21.314 ââââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:21.314 â SingleLocationRequest: 1
09-19 11:12:21.314 â âââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:21.314 ââ đ Location[fused 45.519239,-73.617058 hAcc=15]999923706055 vAcc=2 sAcc=??? bAcc=???
09-19 11:12:21.327 [c.t.l.l.TSLocationManager onSingleLocationResult]
09-19 11:12:21.327 đĩ Acquired motionchange position, isMoving: false
09-19 11:12:21.342 [c.t.l.l.TSLocationManager a] 15.243
09-19 11:12:21.405 [c.t.locationmanager.data.a.c persist]
09-19 11:12:21.405 â
INSERT: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
09-19 11:12:21.423 [c.t.l.http.HttpService flush]
09-19 11:12:21.423 ââââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:21.423 â HTTP Service
09-19 11:12:21.423 â âââââââââââââââââââââââââââââââââââââââââââââ
09-19 11:12:21.446 [c.t.locationmanager.data.a.c first]
09-19 11:12:21.446 â
Locked 1 records
09-19 11:12:21.454 [c.t.l.http.HttpService a]
09-19 11:12:21.454 đĩ HTTP POST: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
09-19 11:12:22.083 [c.t.l.http.HttpService$a onResponse]
09-19 11:12:22.083 đĩ Response: 200
09-19 11:12:22.100 [c.t.locationmanager.data.a.c destroy]
09-19 11:12:22.100 â
DESTROY: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
09-19 11:12:55.226 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
Email the result of Logger.getLog using device's mail client.
Optionalquery: SQLQuerylet Logger = BackgroundGeolocation.logger;
Logger.emailLog("foo@bar.com").then((success) => {
console.log("[emailLog] success");
}).catch((error) => {
console.log("[emailLog] FAILURE: ", error);
});
// Or constrain results by providing a SQLQuery
Logger.emailLog("foo@bar.com", {
start: Date.parse("2019-09-19"),
end: Date.parse("2019-09-20"),
order: Logger.ORDER_ASC,
limit: 1000
});
âšī¸ See also:
Upload the result of getLog to provided url. Provide an optional SQLQuery to contrain results between dates. The file-upload request will attach your configured HttpConfig.headers for authentication.
Optionalquery: SQLQueryBackgroundGeolocation.logger.uploadLog("https://my.server.com/users/123/logs").then((success) => {
console.log("[uploadLog] success");
}).catch((error) => {
console.log("[uploadLog] FAILURE:", error);
});
// Or constrain results by providing a [SQLQuery]:
BackgroundGeolocation.logger.uploadLog("https://my.server.com/users/123/logs", {
start: Date.parse("2019-10-20 09:00"),
end: Date.parse("2019-10-20 11:59")
}).then((success) => {
console.log("[uploadLog] success");
}).catch((error) => {
console.log("[uploadLog] FAILURE:", error);
});
MultiPart File Upload
The SDK will upload the gzipped log-file to your server as a Multi-part file upload, the same log-file as used in emailLog. This is what I see with my Node server at request.files:
app.post("/log", async function(req, res) {
console.log("[body]: ", req.body);
console.log("[files]: ", req.files);
res.status(200).send();
});

Form Part
In addition to the log-file, the SDK will upload a form as well, containing the following parameters:
| Key | Value |
|---|---|
state |
JSON-encoded result of SDK's #getState |
model |
Device model |
manufacturer |
Device manufacturer |
platform |
iOS or Android |
version |
OS version |
Logger API
The Background Geolocation SDK includes powerful logging features for debugging location-tracking problems. The SDK stores log-entries for a period of LoggerConfig.logMaxDays (default
3). The volume of logging events inserted into the database is controlled via LoggerConfig.logLevel.For more information, see the đDebugging Guide.
The
LoggerAPI is accessed via BackgroundGeolocation.logger property:Example
Fetching the Logs:
Logs can be fetched from the SDK in three ways:
Inserting your own log messages
You can even insert your own log messages into the SDK's Log database using the following methods:
ERRORWARNINGDEBUGINFOINFOExample
Example Logs