Remote Log Access APIs

更新时间:
复制 MD 格式

This document describes the APIs provided by the Android Remote Log Access software development kit (SDK).

Set log level

The Remote Log Access SDK provides an API to set the log level. Five log levels are supported, in ascending order: VERBOSE < DEBUG < INFO < WARN < ERROR. The default log level is INFO.

updateLogLevel

Updates the log level.

API definition

static void updateLogLevel(ApmRemoteLogLevel apmRemoteLogLevel)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

apmRemoteLogLevel

ApmRemoteLogLevel

Yes

abnormal

Code examples

import com.aliyun.emas.apm.remote.log.ApmRemoteLog
import com.aliyun.emas.apm.remote.log.ApmRemoteLogLevel

ApmRemoteLog.updateLogLevel(ApmRemoteLogLevel.DEBUG)
import com.aliyun.emas.apm.remote.log.ApmRemoteLog;
import com.aliyun.emas.apm.remote.log.ApmRemoteLogLevel;

ApmRemoteLog.updateLogLevel(ApmRemoteLogLevel.DEBUG);

updateLogLevel

Update the log level.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void updateLogLevel(TLogLevel tLogLevel)

Class

TLogService

Parameters

Parameter

Type

Required

Description

tLogLevel

TLogLevel

Yes

abnormal

Code examples

import com.alibaba.ha.adapter.service.tlog.TLogLevel
import com.alibaba.ha.adapter.service.tlog.TLogService

TLogService.updateLogLevel(TLogLevel.DEBUG)
import com.alibaba.ha.adapter.service.tlog.TLogLevel;
import com.alibaba.ha.adapter.service.tlog.TLogService;

TLogService.updateLogLevel(TLogLevel.DEBUG);

Log printing

The Remote Log Access SDK provides a series of APIs for printing logs based on their level.

v

Prints a VERBOSE level log.

API definition

static void v(String module, String tag, String content)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

logv

Prints a VERBOSE level log.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void logv(String module, String tag, String content)

Class

TLogService

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

d

Prints a DEBUG level log.

API definition

static void d(String module, String tag, String content)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

logd

Prints a DEBUG level log.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void logd(String module, String tag, String content)

Class

TLogService

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

i

Prints an INFO level log.

API definition

static void i(String module, String tag, String content)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

logi

Prints an INFO level log.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void logi(String module, String tag, String content)

Class

TLogService

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

w

Prints a WARN level log.

API definition

static void w(String module, String tag, String content)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

logw

Prints a WARN level log.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void logw(String module, String tag, String content)

Class

TLogService

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

w

Prints a WARN level log that contains exception information.

API definition

static void w(String tag, String content, Throwable t)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

t

Throwable

Yes

The exception information.

logw

Prints a WARN level log that contains exception information.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void logw(String tag, String content, Throwable t)

Class

TLogService

Parameters

Parameter

Type

Required

Description

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

t

Throwable

Yes

The exception information.

e

Prints an ERROR level log.

API definition

static void e(String module, String tag, String content)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

loge

Prints an ERROR level log.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void loge(String module, String tag, String content)

Class

TLogService

Parameters

Parameter

Type

Required

Description

module

String

Yes

The feature module that outputs the log content. This helps you filter logs by source.

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

e

Prints an ERROR level log that contains exception information.

API definition

static void e(String tag, String content, Throwable t)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

t

Throwable

Yes

The exception information.

loge

Prints an ERROR level log that contains exception information.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void loge(String tag, String content, Throwable t)

Class

TLogService

Parameters

Parameter

Type

Required

Description

tag

String

Yes

The keyword for the log. This helps you filter logs by tag.

content

String

Yes

The log message.

t

Throwable

Yes

The exception information.

Actively upload logs

The Remote Log Access SDK provides the ability to actively upload logs.

Note

Active upload only uploads the locally cached logs for the current day.

positiveUploadLog

Triggers an active log upload.

API definition

static void positiveUploadLog(String bizAliyunComment)

Introduced in version

2.6.0

Class

ApmRemoteLog

Parameters

Parameter

Type

Required

Description

bizAliyunComment

String

Yes

A comment for this log upload. Use it to find logs in the console.

Code examples

import com.aliyun.emas.apm.remote.log.ApmRemoteLog

ApmRemoteLog.positiveUploadLog("bizAliyunComment")
import com.aliyun.emas.apm.remote.log.ApmRemoteLog;

ApmRemoteLog.positiveUploadLog("bizAliyunComment");

positiveUploadTlog

Triggers an active log upload.

Note

This API applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

API definition

static void positiveUploadTlog(String bizAliyunComment)

Class

TLogService

Parameters

Parameter

Type

Required

Description

bizAliyunComment

String

Yes

A comment for this log upload. Use it to find logs in the console.

Code examples

import com.alibaba.ha.adapter.service.tlog.TLogService

TLogService.positiveUploadTlog("bizAliyunComment")
import com.alibaba.ha.adapter.service.tlog.TLogService;

TLogService.positiveUploadTlog("bizAliyunComment");

Log levels

The log levels that can be set in the "Set log level" API.

ApmRemoteLogLevel

Introduced in version

2.6.0

The log level class is an enumeration that includes the following values.

public enum ApmRemoteLogLevel {
    ERROR,
    WARN,
    INFO,
    DEBUG,
    VERBOSE
}

TLogLevel

Note

This class applies to SDK versions 2.5.0 and earlier. It is not supported in versions 2.6.0 and later.

The log level class is an enumeration that includes the following values.

public enum TLogLevel {
    ERROR,
    WARN,
    INFO,
    DEBUG,
    VERBOSE
}