Log Service provides the SDK in various languages, such as Java, Python, and Go. You can use the SDK to call Log Service operations and consume logs.

Use the SDK to consume logs

The following example shows how to use the Java SDK to consume data in ShardId. For more information, see SDK Reference.
Client client = new Client(host, accessId, accessKey);

    String cursor = client.GetCursor(project, logStore, shardId, CursorMode.END).GetCursor();
    System.out.println("cursor = " +cursor);
    try {
      while (true) {
        PullLogsRequest request = new PullLogsRequest(project, logStore, shardId, 1000, cursor);
        PullLogsResponse response = client.pullLogs(request);
        System.out.println("cursor = " + cursor + " next_cursor = " + response.getNextCursor());
        if (cursor.equals(response.getNextCursor())) {
        cursor = response.getNextCursor();
    catch(LogException e) {
      System.out.println(e.GetRequestId() + e.GetErrorMessage());

Preview logs in the console

Log preview also consumes logs. You can use a browser to log on to the Log Service console and preview some logs in a Logstore on the dedicated preview page.
  1. Log on to the Log Service console, and then click the target project name.
  2. On the Logstores page, find the target Logstore and click Preview in the Log Consumption column.
  3. On the log preview page, select the shard and the log time range, and then click Preview.
    The log preview page displays the log data of the first 10 packets in the specified time range.