public Log4jLogEvent.Builder getLogEventBuilder(final LogEvent logEvent) {
        val messageModified = ApplicationContextProvider.getMessageSanitizer()
            .map(sanitizer -> sanitizer.sanitize(logEvent.getMessage().getFormattedMessage()))
            .orElseGet(() -> logEvent.getMessage().getFormattedMessage());
        val message = new SimpleMessage(messageModified);
        val contextData = new SortedArrayStringMap(logEvent.getContextData());
        val newLogEventBuilder = Log4jLogEvent.newBuilder()
            .setLevel(logEvent.getLevel())
            .setLoggerName(logEvent.getLoggerName())
            .setLoggerFqcn(logEvent.getLoggerFqcn())
            .setContextData(contextData)
            .setContextStack(logEvent.getContextStack())
            .setEndOfBatch(logEvent.isEndOfBatch())
            .setIncludeLocation(logEvent.isIncludeLocation())
            .setMarker(logEvent.getMarker())
            .setMessage(message)
            .setNanoTime(logEvent.getNanoTime())
            .setThreadName(logEvent.getThreadName())
            .setThrownProxy(logEvent.getThrownProxy())
            .setThrown(logEvent.getThrown())
            .setTimeMillis(logEvent.getTimeMillis());

        try {
            newLogEventBuilder.setSource(logEvent.getSource());
        } catch (final Exception e) {
            newLogEventBuilder.setSource(null);
        }
        return newLogEventBuilder;
    }
Gets log event builder.

@param logEvent the log event
@return the log event builder
core/cas-server-core-logging-api/src/main/java/org/apereo/cas/logging/LoggingUtils.java