Table of Contents

Class DynamicPatternLayout

Namespace
log4net.Layout
Assembly
log4net.dll

A flexible layout configurable with pattern string that re-evaluates on each call.

public class DynamicPatternLayout : PatternLayout, ILayout, IOptionHandler
Inheritance
DynamicPatternLayout
Implements
Inherited Members

Remarks

This class is built on PatternLayout and provides all the features and capabilities of PatternLayout. PatternLayout is a 'static' class in that its layout is done once at configuration time. This class will recreate the layout on each reference.

One important difference between PatternLayout and DynamicPatternLayout is the treatment of the Header and Footer parameters in the configuration. The Header and Footer parameters for DynamicPatternLayout must be syntactically in the form of a PatternString, but should not be marked as type log4net.Util.PatternString. Doing so causes the pattern to be statically converted at configuration time and causes DynamicPatternLayout to perform the same as PatternLayout.

Please see PatternLayout for complete documentation.

<layout type="log4net.Layout.DynamicPatternLayout"> <param name="Header" value="%newline**** Trace Opened Local: %date{yyyy-MM-dd HH:mm:ss.fff} UTC: %utcdate{yyyy-MM-dd HH:mm:ss.fff} ****%newline" /> <param name="Footer" value="**** Trace Closed %date{yyyy-MM-dd HH:mm:ss.fff} ****%newline" /> </layout>

Constructors

DynamicPatternLayout()

Constructs a DynamicPatternLayout using the DefaultConversionPattern

public DynamicPatternLayout()

Remarks

The default pattern just produces the application supplied message.

DynamicPatternLayout(string)

Constructs a DynamicPatternLayout using the supplied conversion pattern

public DynamicPatternLayout(string pattern)

Parameters

pattern string

the pattern to use

Properties

The footer for the layout format.

public override string Footer { get; set; }

Property Value

string

the layout footer

The Footer text will be appended after all the logging events have been formatted and appended.

The pattern will be formatted on each get operation.

Header

The header for the layout format.

public override string Header { get; set; }

Property Value

string

the layout header

Remarks

The Header text will be appended before any logging events are formatted and appended.

The pattern will be formatted on each get operation.