public void logError(final Throwable throwable) {
        HttpStatusCode httpStatus = HttpStatus.INTERNAL_SERVER_ERROR;
        if (throwable instanceof ResponseStatusException) {
            httpStatus = ((ResponseStatusException) throwable).getStatusCode();
        }
        logInfo.setStatus(httpStatus.value());
        logInfo.setTraceId(getTraceId());
        // Do not collect stack
        Object result = ShenyuResultWrap.error(exchange, httpStatus.value(),
                ((HttpStatus) httpStatus).getReasonPhrase(), throwable.getMessage());
        final ShenyuResult<?> shenyuResult = ShenyuResultWrap.shenyuResult();
        Object resultData = shenyuResult.format(exchange, result);
        final Object responseData = shenyuResult.result(exchange, resultData);
        assert null != responseData;
        final byte[] bytes = (responseData instanceof byte[])
                ? (byte[]) responseData
                : responseData.toString().getBytes(StandardCharsets.UTF_8);
        logInfo.setResponseContentLength(bytes.length);
        ShenyuContext shenyuContext = exchange.getAttribute(Constants.CONTEXT);
        assert shenyuContext != null;
        logInfo.setTimeLocal(shenyuContext.getStartDateTime().format(DATE_TIME_FORMATTER));
        logInfo.setModule(shenyuContext.getModule());
        long costTime = DateUtils.acquireMillisBetween(shenyuContext.getStartDateTime(), LocalDateTime.now());
        logInfo.setUpstreamResponseTime(costTime);
        logInfo.setResponseHeader(LogCollectUtils.getHeaders(exchange.getResponse().getHeaders()));
        logInfo.setRpcType(shenyuContext.getRpcType());
        logInfo.setMethod(shenyuContext.getMethod());
        if (StringUtils.isNotBlank(shenyuContext.getRpcType())) {
            logInfo.setUpstreamIp(getUpstreamIp());
        }

        int size = bytes.length;
        String body = new String(bytes, StandardCharsets.UTF_8);
        if (size > 0 && !LogCollectConfigUtils.isResponseBodyTooLarge(size)) {
            logInfo.setResponseBody(body);
        }
        // collect log
        if (Objects.nonNull(logCollector)) {
            // desensitize log
            if (desensitized) {
                logCollector.desensitize(logInfo, keyWordMatch, dataDesensitizeAlg);
            }
            logCollector.collect(logInfo);
        }
    }
@Test
    public void testLogError() throws NoSuchFieldException, IllegalAccessException {
        loggingServerHttpResponse.setExchange(exchange);
        Throwable throwable = new Throwable("error");
        logCollector.start();
        // DefaultLogCollector.getInstance().start();
        loggingServerHttpResponse.logError(throwable);
        Field field = loggingServerHttpResponse.getClass().getDeclaredField("logInfo");
        field.setAccessible(true);
        ShenyuRequestLog shenyuRequestLog = (ShenyuRequestLog) field.get(loggingServerHttpResponse);
        Assertions.assertEquals(shenyuRequestLog.getStatus(), 500);
    }