@ Override public String doLayout ( ILoggingEvent event ) { // Format message String msg = super . doLayout ( event ) . trim ( ) ; // prevent log forging msg = preventLogForging ( msg ) ; // Formatting of exception, remove line breaks IThrowableProxy throwableProxy = event . getThrowableProxy ( ) ; if ( throwableProxy != null ) { StackTraceElementProxy [ ] s = throwableProxy . getStackTraceElementProxyArray ( ) ; if ( s != null && s . length > 0 ) { // Performance: Initialize StringBuilder with (number of StackTrace-Elements + 1)*50 (+1 for Message) StringBuilder sb = new StringBuilder ( s . length * BUFFER_PER_LINE ) ; sb . append ( msg ) ; int len = s . length ; for ( int i = 0 ; i < len ; i ++ ) { sb . append ( LINE_SEP ) . append ( s [ i ] ) ; } msg = sb . toString ( ) ; } } return msg + NEWLINE ; }
Creates formatted String using conversion pattern .