Since https://github.com/elastic/elasticsearch/pull/55774 we log exceptions reaching the RestResponse class on their way back to the client in the "rest.suppressed" logger. Status codes <500 are logged on the Debug and >=500 codes are logged on the Warn level.
However there is some logic that doesn't log these errors if the user has requested "error_trace" in the request parameters.
In this case we don't log. To improve visibility of 500s on the server side logs and to be able to measure and alert on occasions of this status code we should remove this condition and always log 500s (and probably 400s on Debug like already done today).
server/src/main/java/org/elasticsearch/rest/RestResponse.java
}
    protected boolean skipStackTrace() {
        return status() == RestStatus.UNAUTHORIZED;
    }
    private static void build(
        XContentBuilder builder,
        ToXContent.Params params,
        RestStatus status,
        boolean detailedErrorsEnabled,
        Exception e
    ) throws IOException {
        builder.startObject();
        ElasticsearchException.generateFailureXContent(builder, params, e, detailedErrorsEnabled);
        builder.field(STATUS, status.getStatus());
        builder.endObject();
    }
    static RestResponse createSimpleErrorResponse(RestChannel channel, RestStatus status, String errorMessage) throws IOException {
        return new RestResponse(
            status,
            channel.newErrorBuilder().startObject().field("error", errorMessage).field("status", status.getStatus()).endObject()
        );
    }
    public static ElasticsearchStatusException errorFromXContent(XContentParser parser) throws IOException {
        XContentParser.Token token = parser.nextToken();
        ensureExpectedToken(XContentParser.Token.START_OBJECT, token, parser);
        ElasticsearchException exception = null;
        RestStatus status = null;
        String currentFieldName = null;
        while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (token == XContentParser.Token.FIELD_NAME) {