ILayout Format Method | Apache log4net™ SDK Documentation

Implement this method to create your own layout format.

Namespace: log4net.Layout
Assembly: log4net (in log4net.dll) Version: 2.0.8.0-.NET 4.0
Syntax

C#
VB
C++
F#
Copy

    void Format(
    	TextWriter writer,
    	LoggingEvent loggingEvent
    )

    Sub Format (
    	writer As TextWriter,
    	loggingEvent As LoggingEvent
    )

    void Format(
    	TextWriter^ writer,
    	LoggingEvent^ loggingEvent
    )

    abstract Format :
            writer : TextWriter *
            loggingEvent : LoggingEvent -> unit

#### Parameters

writer
  Type: System.IO
  TextWriter
  The TextWriter to write the formatted event to
loggingEvent
  Type: log4net.Core
  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#
Copy

    StringWriter writer = new StringWriter();
    Layout.Format(writer, loggingEvent);
    string formattedEvent = writer.ToString();

See Also

#### Reference

ILayout Interface
log4net.Layout Namespace