Load log4net's XML configuration and insert an XML element in the appender's layout with the header information.
ie:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<layout type=\"log4net.Layout.PatternLayout\">" +
"<conversionPattern value=\"sample\" />" +
"</layout>");
XmlElement root = doc.DocumentElement;
XmlNode layout = doc.SelectSingleNode("//layout");
XmlElement elem = doc.CreateElement("header");
elem.SetAttribute("value", "My Header");
elem.SetAttribute("type", "log4net.Util.PatternString");
layout.AppendChild(elem);
Result:
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="sample" />
<header value="My Header" type="log4net.Util.PatternString" />
</layout>
No comments:
Post a Comment