@GetMapping(path = "/stream", produces = MediaType.APPLICATION_JSON_VALUE)
    @Operation(summary = "Fetch the last X number of log entries from GCP",
        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, defaultValue = "INFO") final String level) {

        val filterBuilder = new StringBuilder("severity=" + level.toUpperCase(Locale.ENGLISH));
        val properties = casProperties.getLogging().getGcp();
        if (StringUtils.isNotBlank(properties.getLogName())) {
            filterBuilder.append(" AND logName=").append(properties.getLogName());
        }
        for (val label : properties.getLabels().entrySet()) {
            filterBuilder.append(" AND resource.labels.").append(label.getKey()).append('=').append(label.getValue());
        }
        val filter = filterBuilder.toString();
        LOGGER.trace("Using filter [{}]", filter);
        
        val logEntries = loggingService.listLogEntries(
            Logging.EntryListOption.filter(filter),
            Logging.EntryListOption.sortOrder(Logging.SortingField.TIMESTAMP, Logging.SortingOrder.DESCENDING),
            Logging.EntryListOption.pageSize(count)
        ).iterateAll().iterator();

        val logEvents = new ArrayList<LogEvent>();
        while (logEntries.hasNext() && logEvents.size() < count) {
            val logEntry = logEntries.next();
            val event = new LogEvent(logEntry.getPayload().getData().toString(),
                DateTimeUtils.zonedDateTimeOf(logEntry.getInstantTimestamp()),
                logEntry.getSeverity().name().toUpperCase(Locale.ENGLISH),
                logEntry.getLabels());
            logEvents.add(event);
        }
        return logEvents;
    }
Fetch log entries as a list.

@param count the count
@param level the level
@return the list
support/cas-server-support-gcp-logging/src/main/java/org/apereo/cas/logging/GoogleCloudLogsEndpoint.java