log4net SDK Reference |

# ILayout.Format Method

Implement this method to create your own layout format.

[Visual Basic]
Sub Format( _
ByVal writer As TextWriter, _
ByVal loggingEvent As LoggingEvent _
)
[C#]
void Format(
TextWriter writer,
LoggingEvent loggingEvent
);

#### Parameters

writer
  The TextWriter to write the formatted event to
loggingEvent
  The event to format

#### Remarks

This method is called by an appender to format the loggingEvent as text and output to a writer.

If the caller does not have a TextWriter and prefers the event to be formatted as a String then the following code can be used to format the event into a StringWriter.

    [C#]
    StringWriter writer = new StringWriter();
    Layout.Format(writer, loggingEvent);
    string formattedEvent = writer.ToString();

#### See Also

ILayout Interface | log4net.Layout Namespace