I have a new class that I implemented several years ago. It provides a
DynamicPatternConverter. Its primary purpose is to provide dynamic
headers and footers in logs.
Below is the description from the code
/// <summary>
/// A flexible layout configurable with pattern string that
re-evaluates on each call.
/// </summary>
/// <remarks>
/// <para>This class is built on <see
cref="PatternLayout"></see> 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.</para>
/// <para>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 staticly converted at configuration tiame and
causes DynamicPatternLayout
/// to perform the same as PatternLayout.</para>
/// <para>Please see <see cref="PatternLayout"/> for complete
documentation.</para>
/// <example>
/// <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>
/// </example>
/// </remarks>
I do not have test cases. This code is available for inclusion in
log4Net if anyone feels that it is worth including. I like it because I
can scan through a logfile and find out when it was closed and/or
opened. (Append = true). The entire module is 142 lines including
comments.
----------------------------------------------------------------------
Roy Chastain