@GetMapping(path = "/stream", produces = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "Fetch the last X number of log entries from AWS cloud watch",
        parameters = {
            @Parameter(name = "count", in = ParameterIn.QUERY, description = "The number of log entries to fetch", required = false),
            @Parameter(name = "level", in = ParameterIn.QUERY, description = "The log level to filter statements", required = false)
        })
    public List<LogEvent> fetchLogEntries(@RequestParam(name = "count", required = false, defaultValue = "50") final int count,
                                          @RequestParam(name = "level", required = false) final String level) {
        val cloudwatch = casProperties.getLogging().getCloudwatch();
        val logEventsRequest = GetLogEventsRequest
            .builder()
            .logGroupName(cloudwatch.getLogGroupName())
            .logStreamName(cloudwatch.getLogStreamName())
            .limit(count)
            .startFromHead(false)
            .unmask(true)
            .build();
        val logEventsResponse = awsLogsClient.getObject().getLogEvents(logEventsRequest);
        return logEventsResponse
            .events()
            .stream()
            .map(event -> {
                var message = event.message().trim();
                val matcher = LOG_LEVEL_PATTERN.matcher(message);
                var logLevel = "INFO";
                if (matcher.find()) {
                    logLevel = matcher.group(2).toUpperCase(Locale.ENGLISH);
                    message = StringUtils.remove(message, matcher.group(1)).trim();
                }
                return new LogEvent(message, DateTimeUtils.zonedDateTimeOf(event.timestamp()), logLevel);
            })
            .filter(event -> StringUtils.isBlank(level) || event.level().equalsIgnoreCase(level))
            .toList();
    }
Fetch log entries as a list.

@param count the count
@return the list
support/cas-server-support-aws-cloudwatch/src/main/java/org/apereo/cas/logging/CloudWatchLogsEndpoint.java