Table of Contents

Class PatternConverter

Namespace
log4net.Util
Assembly
log4net.dll

Abstract class that provides the formatting functionality that derived classes need.

public abstract class PatternConverter
Inheritance
PatternConverter
Derived
Inherited Members

Remarks

Conversion specifiers in a conversion patterns are parsed to individual PatternConverters. Each of which is responsible for converting a logging event in a converter specific manner.

Constructors

PatternConverter()

Protected constructor

protected PatternConverter()

Remarks

Initializes a new instance of the PatternConverter class.

Properties

FormattingInfo

Gets or sets the formatting info for this converter

public virtual FormattingInfo FormattingInfo { get; set; }

Property Value

FormattingInfo

The formatting info for this converter

Remarks

Gets or sets the formatting info for this converter

Next

Get the next pattern converter in the chain

public virtual PatternConverter Next { get; }

Property Value

PatternConverter

the next pattern converter in the chain

Remarks

Get the next pattern converter in the chain

Option

Gets or sets the option value for this converter

public virtual string Option { get; set; }

Property Value

string

Remarks

Gets or sets the option value for this converter

Properties

public PropertiesDictionary Properties { get; set; }

Property Value

PropertiesDictionary

Methods

Convert(TextWriter, object)

Evaluate this pattern converter and write the output to a writer.

protected abstract void Convert(TextWriter writer, object state)

Parameters

writer TextWriter

TextWriter that will receive the formatted result.

state object

The state object on which the pattern converter should be executed.

Remarks

Derived pattern converters must override this method in order to convert conversion specifiers in the appropriate way.

Format(TextWriter, object)

Write the pattern converter to the writer with appropriate formatting

public virtual void Format(TextWriter writer, object state)

Parameters

writer TextWriter

TextWriter that will receive the formatted result.

state object

The state object on which the pattern converter should be executed.

Remarks

This method calls Convert(TextWriter, object) to allow the subclass to perform appropriate conversion of the pattern converter. If formatting options have been specified via the FormattingInfo then this method will apply those formattings before writing the output.

SetNext(PatternConverter)

Set the next pattern converter in the chains

public virtual PatternConverter SetNext(PatternConverter patternConverter)

Parameters

patternConverter PatternConverter

the pattern converter that should follow this converter in the chain

Returns

PatternConverter

the next converter

Remarks

The PatternConverter can merge with its neighbor during this method (or a sub class). Therefore the return value may or may not be the value of the argument passed in.

SpacePad(TextWriter, int)

Fast space padding method.

protected static void SpacePad(TextWriter writer, int length)

Parameters

writer TextWriter

TextWriter to which the spaces will be appended.

length int

The number of spaces to be padded.

Remarks

Fast space padding method.

WriteDictionary(TextWriter, ILoggerRepository, IDictionary)

Write an dictionary to a TextWriter

protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionary value)

Parameters

writer TextWriter

the writer to write to

repository ILoggerRepository

a ILoggerRepository to use for object conversion

value IDictionary

the value to write to the writer

Remarks

Writes the IDictionary to a writer in the form:

{key1=value1, key2=value2, key3=value3}

If the ILoggerRepository specified is not null then it is used to render the key and value to text, otherwise the object's ToString method is called.

WriteDictionary(TextWriter, ILoggerRepository, IDictionaryEnumerator)

Write an dictionary to a TextWriter

protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionaryEnumerator value)

Parameters

writer TextWriter

the writer to write to

repository ILoggerRepository

a ILoggerRepository to use for object conversion

value IDictionaryEnumerator

the value to write to the writer

Remarks

Writes the IDictionaryEnumerator to a writer in the form:

{key1=value1, key2=value2, key3=value3}

If the ILoggerRepository specified is not null then it is used to render the key and value to text, otherwise the object's ToString method is called.

WriteObject(TextWriter, ILoggerRepository, object)

Write an object to a TextWriter

protected static void WriteObject(TextWriter writer, ILoggerRepository repository, object value)

Parameters

writer TextWriter

the writer to write to

repository ILoggerRepository

a ILoggerRepository to use for object conversion

value object

the value to write to the writer

Remarks

Writes the Object to a writer. If the ILoggerRepository specified is not null then it is used to render the object to text, otherwise the object's ToString method is called.