Skip to content

Logging a message

This API sends a message string to a log file.

Method:

PUT

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

https://xxxx.backendless.app/api/log

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

Make sure to replace xxxx in the domain name in the sample request below to the one assigned to your application.

curl -H Content-Type:application/json -X PUT \  
-v  https://xxxx.backendless.app/api/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

Codeless Reference

logging_api_log_a_message_1

where:

Argument                Description
logger name Represents a unique identifier assigned to a logger, which serves as a gateway for submitting client-side log messages. Each logger can represent a specific UI screen name or functional area within the application.
log channel Identifies a specific logging level, available options are: DEBUG, INFO, WARN, ERROR, FATAL, TRACE.
log message Specify the log message to be saved in the log file.

The example below creates a new logger with the name "event_listener_create", sets the logging level to DEBUG and saves the log message to the log file.

logging_api_log_a_message_2

After the Codeless logic runs, the log gets printed to the REAL-TIME LOGGING interface:

logging_api_log_a_message_3