implementation(group: 'com.tencentcloudapi.cls', name: 'tencentcloud-cls-sdk-android', version: '1.0.13')
Variable | Type | Required | Description |
endpoint | String | Yes | Regional information. For completion, refer to the domain name in the Log upload via API Tab under available region. |
secretId | String | Yes | TencentCloud API key information. For key information acquisition, please visit API key management. Please ensure the associated account has appropriate SDK log upload permission. |
secretKey | String | Yes | TencentCloud API key information. For key information acquisition, please visit API key management. Please ensure the associated account has appropriate SDK log upload permission. |
topicId | String | Yes | Log topic ID info. |
public static void main(String[] args) {String endpoint = "ap-xxxxxx.cls.tencentcs.com";// API key secretId, required.String secretId = "";// API key secretKey, required.String secretKey = "";// Log topic ID, required.String topicId = "";// NetworkUtils.getLocalMachineIP() retrieves the local network interface ip. If not specified, it populates by default with the network outbound ip received by the server.final AsyncProducerConfig config = new AsyncProducerConfig(endpoint, secretId, secretKey, "", NetworkUtils.getLocalMachineIP());// Build a client instance.final AsyncProducerClient client = new AsyncProducerClient(config);for (int i = 0; i < 10000; ++i) {List<LogItem> logItems = new ArrayList<>();int ts = (int) (System.currentTimeMillis() / 1000);LogItem logItem = new LogItem(ts);logItem.PushBack(new LogContent("__CONTENT__", "hello world"));logItem.PushBack(new LogContent("city", "xxxxxxx"));logItem.PushBack(new LogContent("logNo", Integer.toString(i)));logItem.PushBack(new LogContent("__PKG_LOGID__", (String.valueOf(System.currentTimeMillis()))));logItems.add(logItem);client.putLogs(topicId, logItems, result -> System.out.println(result.toString()));}client.close();}
Feedback