@Override
	public LogEvent rewrite(LogEvent source) {
		// get the markers for the log event. If no markers, nothing can be
		// tagged confidential and we can return
		Marker sourceMarker = source.getMarker();
		if (sourceMarker == null) {
			return source;
		}

		// get the message. If no message we can return
		final Message msg = source.getMessage();
		if (msg == null || !(msg instanceof ParameterizedMessage)) {
			return source;
		}

		// get the parameters. If no params we can return
		Object[] params = msg.getParameters();
		if (params == null || params.length == 0) {
			return source;
		}

		// check if this event is actually marked as confidential. If not,
		// return
		Log4jMarker eventMarker = new Log4jMarker(sourceMarker);
		if (!eventMarker.contains(SecurityMarkers.CONFIDENTIAL)) {
			return source;
		}

		// we have a message, parameters, a marker, and it is confidential.
		// Process
		for (int i = 0; i < params.length; i++) {
			params[i] = MASKED_PASSWORD;
		}

		// create new message
		Message outMessage = new ParameterizedMessage(msg.getFormat(), params,
				msg.getThrowable());

		// build new log event for output
		LogEvent output = new Log4jLogEvent.Builder(source)
				.setMessage(outMessage).build();

		return output;
	}
@ Override public LogEvent rewrite ( LogEvent source ) { Marker sourceMarker = source . getMarker ( ) ; if ( sourceMarker == null ) { return source ; } final Message msg = source . getMessage ( ) ; if ( msg == null || ! ( msg instanceof ParameterizedMessage ) ) { return source ; } Object [ ] params = msg . getParameters ( ) ; if ( params == null || params . length == 0 ) { return source ; } Log4jMarker eventMarker = new Log4jMarker ( sourceMarker ) ; if ( ! eventMarker . contains ( SecurityMarkers . CONFIDENTIAL ) ) { return source ; } for ( int i = 0 ; i < params . length ; i ++ ) { params [ i ] = MASKED_PASSWORD ; } Message outMessage = new ParameterizedMessage ( msg . getFormat ( ) , params , msg . getThrowable ( ) ) ; LogEvent output = new Log4jLogEvent . Builder ( source ) . setMessage ( outMessage ) . build ( ) ; return output ; }
Rewrite the event.

@param source a logging event that may be returned or used to create a
new logging event.
@return The LogEvent after rewriting.