Log Service provides SDKs that are developed in multiple programming languages. You can use one of the SDKs to consume log data. This topic describes how to use an SDK to consume log data. The topic also describes how to use the consumption preview feature to consume log data in the Log Service console.

Use an SDK to consume log data

The following example shows how to use Log Service SDK for Java to consume log data from a shard. For more information about the SDK, see Java SDK.
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());
For more information about Log Service SDKs, see Log Service SDKs.

Consumption preview

Consumption preview is a type of log data consumption. The consumption preview feature allows you to preview some log data that is stored in LogHub in the Log Service console.

  1. Log on to the Log Service console.
  2. In the Projects section, click the project from which you want to consume log data.
  3. On the page that appears, choose Log Storage > Logstores. In the Logstores pane, find the Logstore from which you want to consume log data and choose Log preview > Consumption Preview.
  4. In the Consumption Preview panel, select a shard and a time range, and click Preview.
    The Consumption Preview panel displays the log data of the first 10 packets in the specified time range.