title: How to get Latest Log Stream Name Using Java
body: <p>How do we get the latest log stream name from a given log group using java code.
  I have tried many possibilities and still not able to retrieve it.</p>
  <pre><code>AWSLogs awsLogs = AWSLogsClientBuilder
                  .standard()
                  .withCredentials(new AWSStaticCredentialsProvider(credentials))
                  .withRegion(Regions.EU_WEST_1)
                  .build();
  
  DescribeLogStreamsRequest describeLogStreamsRequest = new DescribeLogStreamsRequest()
      .withLogGroupName(&quot;/aws/lambda/a250348-ecndesc-conversion-lambda-reci-euw1-qe&quot;);
  describeLogStreamsResult = awsLogs.describeLogStreams(describeLogStreamsRequest);
  System.out.println(describeLogStreamsResult.getLogStreams());
  
  for(int i =0; i&lt;describeLogStreamsResult.getLogStreams().size(); i++) {
      logStream = describeLogStreamsResult.getLogStreams().get(i).getLastEventTimestamp();
      Date date = new Date(logStream);
      dateList.add(date);         
  }
  latestDate = Collections.max(dateList);
  System.out.println(latestDate);
  
  System.out.println(dateList.indexOf(latestDate));
  logStream1 = describeLogStreamsResult.getLogStreams().get(dateList.indexOf(latestDate)).getLogStreamName();
  
  System.out.println(logStream1);
  </code></pre>