Log Configuration¶
Log Initialization Configuration¶
| Method Name | Type | Required | Description |
|---|---|---|---|
| setSamplingRate | Float | No | Sets the sampling rate. Value range [0,1]. 0 means no collection, 1 means full collection. Default value is 1. |
| setEnableConsoleLog | Boolean | No | Whether to report console logs. This configuration depends on ft-plugin. Default is false. The log level mapping is: Log.v -> ok, Log.i -> info, Log.d -> debug, Log.e -> error, Log.w -> warning. prefix is the prefix filter parameter. No filter is set by default. Note: Android console logs can be very large. To avoid impacting application performance and reduce unnecessary resource waste, it is recommended to use prefix to filter for valuable logs. ft-plugin version 1.3.5 and above supports capturing logs printed by Log.println. |
| setEnableLinkRUMData | Boolean | No | Whether to correlate with RUM data. Default is false. |
| setEnableCustomLog | Boolean | No | Whether to upload custom logs. Default is false. |
| setLogLevelFilters | Array | No | Sets log level filters. Not set by default. |
| addGlobalContext | Dictionary | No | Adds global attributes for logs. For addition rules, please refer to here. |
| setLogCacheLimitCount | Int | No | Sets the maximum number of log entries for local cache limit [1000,). Larger logs mean greater disk cache pressure. Default is 5000. |
| setLogCacheDiscardStrategy | LogCacheDiscard | No | Sets the log discard rule when the limit is reached. Default is LogCacheDiscard.DISCARD. DISCARD discards the appended data, DISCARD_OLDEST discards the oldest data. |
Logger Log Printing¶
Custom log output is performed by using FTLogger. Requires enabling FTLoggerConfig.setEnableCustomLog(true).
Currently, the log content is limited to 30 KB. Characters exceeding this limit will be truncated.
Usage¶
/**
* Stores a single log data locally synchronously.
*
* @param content Log content
* @param status Log level, enum Status
* @param property Additional attributes (optional)
*/
public void logBackground(String content, Status status, HashMap<String, Object> property)
/**
* Stores a single log data locally synchronously.
*
* @param content Log content
* @param status Log level, String
* @param property Additional attributes (optional)
*/
public void logBackground(String content, String status, HashMap<String, Object> property)
/**
* Stores multiple log data locally synchronously.
*
* @param logDataList List of {@link LogData}
*/
public void logBackground(List<LogData> logDataList)
/**
* Stores a single log data locally synchronously.
*
* @param content Log content
* @param status Log level
* @param property Log attributes (optional)
*/
fun logBackground(content: String, status: Status, property: HashMap<String, Any>)
/**
* Stores a single log data locally synchronously.
*
* @param content Log content
* @param status Log level
* @param property Log attributes (optional)
*/
fun logBackground(content: String, status: String, property: HashMap<String, Any>)
/**
* Stores multiple log data locally synchronously.
*
* @param logDataList List of log data
*/
fun logBackground(logDataList: List<LogData>)
Log Levels¶
| Method Name | Description |
|---|---|
| Status.DEBUG | Debug |
| Status.INFO | Info |
| Status.WARNING | Warning |
| Status.ERROR | Error |
| Status.CRITICAL | Critical |
| Status.OK | OK |
Code Examples¶
// Upload a single log
FTLogger.getInstance().logBackground("test", Status.INFO);
// Pass parameters to HashMap
HashMap<String, Object> map = new HashMap<>();
map.put("ft_key", "ft_value");
FTLogger.getInstance().logBackground("test", Status.INFO, map);
// Batch upload logs
List<LogData> logList = new ArrayList<>();
logList.add(new LogData("test", Status.INFO));
FTLogger.getInstance().logBackground(logList);
// Upload a single log
FTLogger.getInstance().logBackground("test", Status.INFO)
// Pass parameters to HashMap
val map = HashMap<String, Any>()
map["ft_key"] = "ft_value"
FTLogger.getInstance().logBackground("test", Status.INFO, map)
// Batch upload logs
FTLogger.getInstance().logBackground(mutableListOf(LogData("test", Status.INFO)))