Log Configuration¶
| Field | Type | Required | Description |
|---|---|---|---|
| logSamplingRate | double | No | Log sampling rate, range [0,100], supports decimals, default 100. 0.1 means 0.1%, and 1 means 1%. Supported since SDK 0.5.8. |
| sampleRate | double | No | Legacy probability configuration, retained for compatibility. Log sampling rate, range [0,1], default 1. 0.1 means 10%, and 1 means 100%. Using logSamplingRate is recommended. |
| enableWebViewLog | bool | No | Whether to collect logs from the Web monitoring SDK in WebView. Default false. This must be used together with allowWebViewHost in the basic configuration and the Web monitoring SDK on the page. Supported since SDK 0.5.8. See WebView Data Monitoring for details. |
| enableLinkRumData | bool | No | Whether to associate with RUM |
| enableCustomLog | bool | No | Whether to enable custom logs |
| logLevelFilters | List<FTLogStatus> |
No | Log level filters |
| logCacheLimitCount | int | No | Maximum number of log entries in the local cache [1000, ), default 5000 |
| discardStrategy | enum FTLogCacheDiscard | No | Sets the discard rule after logs reach the limit. Defaults to FTLogCacheDiscard.discard; discard discards appended data, and discardOldest discards old data |
Percentage Sampling Migration¶
Supported since SDK 0.5.8.
Sampling Rate Parameter Naming
Since SDK 0.5.8, logSamplingRate is recommended. Its value is a percentage from 0 to 100, and decimals are supported; 0 means no sampling, and 100 means full sampling. Invalid values such as out-of-range values, NaN, or infinity throw an ArgumentError.
The legacy sampleRate remains supported for compatibility. Its value is a probability from 0 to 1. For example, 0.1 in the legacy field means 10%, while 0.1 in the new field means 0.1%. When both fields are set, the new percentage field takes precedence, including an explicit 0.
For the units and priority of remote sampling fields, see Flutter Remote Configuration Fields.
For example, to migrate 12.5% Log sampling:
Logger Log Printing¶
Custom Logs¶
Currently, log content is limited to 30 KB. Characters exceeding this limit are truncated.
Usage¶
/// Output logs
/// [content] Log content
/// [status] Log status
/// [property] Additional property parameters (optional)
Future<void> logging(String content, FTLogStatus status,
{Map<String, String>? property})
Code Example¶
Log Levels¶
| Method Name | Meaning |
|---|---|
| FTLogStatus.info | Info |
| FTLogStatus.warning | Warning |
| FTLogStatus.error | Error |
| FTLogStatus.critical | Critical |
| FTLogStatus.ok | Recovery |