public String format( KettleLoggingEvent event ) {
    // OK, perhaps the logging information has multiple lines of data.
    // We need to split this up into different lines and all format these
    // lines...
    //
    StringBuilder line = new StringBuilder();

    String dateTimeString = "";
    if ( timeAdded ) {
      if ( LOCAL_SIMPLE_DATE_PARSER.get() == null ) {
        LOCAL_SIMPLE_DATE_PARSER.set( getLog4j2Appender() );
      }
      dateTimeString = LOCAL_SIMPLE_DATE_PARSER.get().format( new Date( event.timeStamp ) ) + " - ";
    }

    Object object = event.getMessage();
    if ( object instanceof LogMessage ) {
      LogMessage message = (LogMessage) object;

      String[] parts = message.getMessage() == null ? new String[] {} : message.getMessage().split( Const.CR );
      for ( int i = 0; i < parts.length; i++ ) {
        // Start every line of the output with a dateTimeString
        line.append( dateTimeString );

        // Include the subject too on every line...
        if ( message.getSubject() != null ) {
          line.append( message.getSubject() );
          if ( message.getCopy() != null ) {
            line.append( "." ).append( message.getCopy() );
          }
          line.append( " - " );
        }

        if ( i == 0 && message.isError() ) {
          BuildVersion buildVersion = BuildVersion.getInstance();
          line.append( ERROR_STRING );
          line.append( " (version " );
          line.append( buildVersion.getVersion() );
          if ( !Utils.isEmpty( buildVersion.getRevision() ) ) {
            line.append( ", build " );
            line.append( buildVersion.getRevision() );
          }
          if ( !Utils.isEmpty( buildVersion.getBuildDate() ) ) {
            line.append( " from " );
            line.append( buildVersion.getBuildDate() );
          }
          if ( !Utils.isEmpty( buildVersion.getBuildUser() ) ) {
            line.append( " by " );
            line.append( buildVersion.getBuildUser() );
          }
          line.append( ") : " );
        }

        line.append( parts[i] );
        if ( i < parts.length - 1 ) {
          line.append( Const.CR ); // put the CR's back in there!
        }
      }
    } else {
      line.append( dateTimeString );
      line.append( ( object != null ? object.toString() : "<null>" ) );
    }

    return line.toString();
  }
@Test
  public void testFormat() throws Exception {
    LogMessage mcg = new LogMessage( "Log message for {0}",
        "Channel 01",
        new String[]{ "Test" },
        LogLevel.DEBUG );
    mcg.setSubject( "Subject" );

    KettleLoggingEvent event = new KettleLoggingEvent( mcg, 0, LogLevel.BASIC );
    KettleLogLayout layout = new KettleLogLayout();

    final String formattedMsg = layout.format( event );

    Assert.assertEquals( "The log message must be formatted and not contain placeholders.",
        "Subject - Log message for Test",
        formattedMsg.substring( formattedMsg.indexOf( '-' ) + 2 ) );
  }