// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Xml; using log4net; using log4net.Config; using log4net.Appender; using log4net.Layout; using log4net.Core; namespace E { public class MyXmlLayout : XmlLayoutBase { protected override void FormatXml(XmlWriter wrt, LoggingEvent logevt) { wrt.WriteStartElement("LogEntry"); wrt.WriteStartElement("Message"); wrt.WriteString(logevt.RenderedMessage); wrt.WriteEndElement(); wrt.WriteEndElement(); } } public class Test { public static void Main(string[] args) { XmlConfigurator.Configure(); ILog log = LogManager.GetLogger("Test"); log.Fatal("Just testing"); log.Error("Just testing"); log.Warn("Just testing"); log.Info("Just testing"); log.Debug("Just testing"); } } }