Skip to content

Logging a message

This API logs a message and or error to the server. If the log buffer is configured, the message is stored in it for subsequent flush, otherwise, the log message is delivered to the server.All methods are available on the logger object retrieved using the method described above:

Future<void> debug(String message)
Future<void> info(String message)
Future<void> warn(String message, [Exception e])
Future<void> error(String message, [Exception e])
Future<void> fatal(String message, [Exception e])
Future<void> trace(String message)

where:

Argument                Description
message the message to log.
e an exception or error to log. Backendless logs a stack trace for the exception.

Example

Logger logger = Backendless.logging.getLogger("com.mbaas.Logger");
logger.info("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