This document describes the Remote Log APIs provided by the App Monitor iOS software development kit (SDK). These APIs allow you to record logs and adjust log levels.
1. Get a log instance
Create a log instance using the EAPMRemoteLogFactory factory method.
API definition
#import "AlicloudApmRemoteLog/EAPMRemoteLog.h"
+ (EAPMRemoteLog *)createLogForModuleName:(NSString*)moduleName;#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
class func createLog(moduleName: String)Code example
#import "AlicloudApmRemoteLog/EAPMRemoteLog.h"
EAPMRemoteLog *log = [EAPMRemoteLogFactory createLogForModuleName:@"YourModuleName"];#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
let log = RemoteLogFactory.createLog(moduleName: "YourModuleName")2. Record logs
Use the EAPMRemoteLog instance to record logs of different log levels.
API definition
#import "AlicloudApmRemoteLog/EAPMRemoteLog.h"
/**
* Records a debug level log.
*
* @param message The log content to record.
*/
- (void)debug:(NSString *)message;
/**
* Records a debug level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
- (void)debug:(NSString *)message exception:(NSException *)exception;
/**
* Records an info level log.
*
* @param message The log content to record.
*/
- (void)info:(NSString *)message;
/**
* Records an info level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
- (void)info:(NSString *)message exception:(NSException *)exception;
/**
* Records a warn level log.
*
* @param message The log content to record.
*/
- (void)warn:(NSString *)message;
/**
* Records a warn level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
- (void)warn:(NSString *)message exception:(NSException *)exception;
/**
* Records an error level log.
*
* @param message The log content to record.
*/
- (void)error:(NSString *)message;
/**
* Records an error level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
- (void)error:(NSString *)message exception:(NSException *)exception;#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
/**
* Records a debug level log.
*
* @param message The log content to record.
*/
func debug(message: String)
/**
* Records a debug level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
func debug(message: String, exception: NSException)
/**
* Records an info level log.
*
* @param message The log content to record.
*/
func info(message: String)
/**
* Records an info level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
func info(message: String, exception: NSException)
/**
* Records a warn level log.
*
* @param message The log content to record.
*/
func warn(message: String)
/**
* Records a warn level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
func warn(message: String, exception: NSException)
/**
* Records an error level log.
*
* @param message The log content to record.
*/
func error(message: String)
/**
* Records an error level log with an exception object.
*
* @param message The log content to record.
* @param exception The exception object.
*/
func error(message: String, exception: NSException)Custom log parameters
Parameter | Type | Required | Description |
message | NSString | Yes | Records a log message. |
exception | NSException | No | The exception object. Only its description property is recorded. |
Code example
#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
EAPMRemoteLog *log = [EAPMRemoteLogFactory createLogForModuleName:@"BazingaModule"];
[log error:@"error message"];
[log warn:@"warn message"];
[log debug:@"debug message"];
[log info:@"info message"];#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
let log = RemoteLogFactory.createLog(moduleName: "YourModuleName")
log.error("error message")
log.warn("warn message")
log.debug("debug message")
log.info("info message")3. Adjust the log level
Use the EAPMRemoteLog class to adjust the log recording level. The default level is debug.
API definition
#import "AlicloudApmRemoteLog/EAPMRemoteLog.h"
+ (EAPMRemoteLogLevel)updateLogLevel:(EAPMRemoteLogLevel)logLevel;#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
class func updateLogLevel(logLevel: EAPMRemoteLogLevel) -> EAPMRemoteLogLevelEAPMRemoteLogLevel enumeration
Parameter | Description |
EAPMRemoteLogLevelOFF | Shutdown level |
EAPMRemoteLogLevelError | Error level |
EAPMRemoteLogLevelWarn | Warning level |
EAPMRemoteLogLevelInfo | Info level |
EAPMRemoteLogLevelDebug | Debug level |
Code example
#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
[EAPMRemoteLog updateLogLevel:EAPMRemoteLogLevelError];#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
RemoteLog.updateLogLevel(EAPMRemoteLogLevel.error)4. Actively report logs
Use the EAPMRemoteLog class to manually report the logs recorded on the current day.
API definition
#import "AlicloudApmRemoteLog/EAPMRemoteLog.h"
+ (void)uploadTLog:(NSString *)bizComment;#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
static func uploadTLog(_ bizComment: String)Parameters for manually reporting logs
Parameter | Type | Required | Description |
bizComment | NSString | Yes | Comment |
Code example
#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
[EAPMRemoteLog uploadTLog:@"Your bizComment"];#import "AlicloudApmRemoteLog/AlicloudApmRemoteLog.h"
RemoteLog.uploadTLog("Your bizComment")