Skip to content

Logging a message

This API sends a message string to a log file.

Method:

PUT

URL

https://api.backendless.com/<application id>/<REST-api-key>/log

where:

Argument                Description
<application id> ID of the application which can be obtained from the Manage > App Settings screen of the Backendless Console
<REST-api-key> REST API key of your application. You can get the value from the Manage > App Settings section of the Backendless Console.

Request headers

Content-Type: application/json  
user-token: optional value obtained as a result of the login operation.

where:

Argument                Description
Content-Type Must be set to application/json. This header is mandatory.
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-token is set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved.  Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request body

A JSON array of objects. Each object represents a log message.

[  
  {  
    "log-level": DEBUG | INFO | TRACE | WARN | ERROR | FATAL,  
    "logger":value,  
    "timestamp":value,  
    "message": message-text-value,  
    "exception":error-text-value   
  }  
]

Response body

none or error

Example

curl -H Content-Type:application/json -X PUT \  
-v  https://api.backendless.com/XXXX-XXXX-XXXX/ZZZZ-ZZZZ-ZZZZ/log \  
-d '[{"log-level":"INFO","logger":"com.mbaas.Logger","timestamp":123456789, "message":"Starting application.." }]'

Once the example runs, the Manage > Log Management screen in the Backendless Console will show the following:
log-file-sample.zoom50