Log Configuration¶
This document describes the Log initialization configuration and log printing instructions for the C++ SDK.
Initialize Log¶
FTLogConfig lpc;
// std::vector<LogLevel> llf;
// llf.push_back(LogLevel::ERR);
// lpc.setLogLevelFilters(llf);
lpc.setEnableCustomLog(true)
.setEnableLinkRumData(true);
sdk->initLogWithConfig(lpc);
| Field | Type | Required | Description |
|---|---|---|---|
setSamplingRate |
float | No | Sampling rate range [0,1]. 0 means no collection, 1 means full collection. Default value is 1. |
addGlobalContext |
dictionary | No | Add tag data. For rules, please read Custom Tags. |
setLogLevelFilters |
array | No | Set log level filters. Not set by default. |
setEnableCustomLog |
bool | No | Whether to upload custom logs. Default is false. |
setEnableLinkRUMData |
bool | No | Whether to associate with RUM data. Default is false. |
setLogCacheDiscardStrategy |
LogCacheDiscard | No | Default is LogCacheDiscard::DISCARD. DISCARD discards the appended data, DISCARD_OLDEST discards the oldest data. |
Log Printing¶
/**
* Upload user logs to DataKit
*
* @param content Log content
* @param level Log level
*/
void addLog(std::string content, LogLevel level);
Example: