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:

- (void)debugWithMessage:(NSString * _Nonnull)message;
- (void)infoWithMessage:(NSString * _Nonnull)message;
- (void)traceWithMessage:(NSString * _Nonnull)message;
- (void)warnWithMessage:(NSString * _Nonnull)message;
- (void)warnWithMessage:(NSString * _Nonnull)message exception:(NSException * _Nonnull)exception;
- (void)errorWithMessage:(NSString * _Nonnull)message;
- (void)errorWithMessage:(NSString * _Nonnull)message exception:(NSException * _Nonnull)exception;
- (void)fatalWithMessage:(NSString * _Nonnull)message;
- (void)fatalWithMessage:(NSString * _Nonnull)message exception:(NSException * _Nonnull)exception;
func debug(message: String)
func info(message: String)
func trace(message: String)
func warn(message: String)
func warn(message: String, exception: NSException)
func error(message: String)
func error(message: String, exception: NSException)
func fatal(message: String)
func fatal(message: String, exception: NSException)

where:

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

Example

Logger *logger = [Backendless.shared.logging getLoggerWithLoggerName:@"com.mbaas.Logger"];
[logger infoWithMessage:@"Starting application..."];
let logger = Backendless.shared.logging.getLogger(loggerName: "com.mbaas.Logger")
logger.info(message: "Starting application...")

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