I have create the custom xml layout using this post. i need log message with character <
but in log file it converted to <
this is my code sample
public class MyXmlLayout : XmlLayoutBase
{
protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
{
writer.WriteStartElement("LogEntry");
writer.WriteStartElement("Exception");
writer.WriteString("<![CDATA[\n" + loggingEvent.GetExceptionString() + "\n]]>");
writer.WriteEndElement();
writer.WriteEndElement();
}
}
Output log file
<LogEntry>
<Exception><![CDATA[
System.DivideByZeroException: Attempted to divide by zero.
at ConsoleApplication5.Program.Main(String[] args) in c:\Users\MahendranM\Documents\Visual Studio 2013\Projects\ConsoleApplication5\ConsoleApplication5\Program.cs:line 24
]]>
</Exception>
</LogEntry>
How can print raw character like <,>
in log4net?