Skip to content

Log Configuration

This document is used to carry the HarmonyOS Log initialization configuration.

Initialization Configuration

import { FTSDK } from '@guancecloud/ft_sdk/src/main/ets/components/FTSDK';
import { FTLoggerConfig } from '@guancecloud/ft_sdk/src/main/ets/components/Configs';
import { Status } from '@guancecloud/ft_sdk/src/main/ets/components/bean/Status';

const logConfig = new FTLoggerConfig()
  .setSamplingRate(1.0)
  .setEnableCustomLog(true)
  .setLogCacheLimitCount(10000)
  .setLogLevelFiltersString([
    Status.ERROR.name,
    Status.WARNING.name,
    Status.INFO.name,
    Status.DEBUG.name
  ])
  .setEnableLinkRumData(true);

FTSDK.installLogConfig(logConfig);
Method Type Required Description
setSamplingRate number No Log sampling rate, range [0.0, 1.0], default 1.0
setEnableCustomLog boolean No Whether to enable custom logs, default false
setLogCacheLimitCount number No Log cache limit count, default 5000, minimum 1000
setLogLevelFiltersString string[] No Log level filter, optional values: ERROR, WARNING, INFO, DEBUG
setEnableLinkRumData boolean No Whether to associate RUM data, default false

Usage Suggestions

  • During the debugging phase, you can combine setEnableCustomLog(true) with SDK Debug logs to verify the collection pipeline.
  • If you want logs to be analyzed in conjunction with user behavior, View and resource data, it is recommended to also enable setEnableLinkRumData(true).
  • If the log volume is large, you can control the upload volume through sampling rate and level filtering.