logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hart, Leo" <Leo.H...@FMR.COM>
Subject RE: LayoutSkeleton Help
Date Thu, 15 Sep 2005 20:16:14 GMT
It looks like you are missing a "<" in this line:

	writer.Write("<ClassName>" +
loggingEvent.LocationInformation.ClassName + "/ClassName>");

Does that fix the problem?
 

	-----Original Message-----
	From: Jon Finley [mailto:jdf@gksys.com] 
	Sent: Thursday, September 15, 2005 4:13 PM
	To: 'Log4NET User'
	Subject: LayoutSkeleton Help
	
	

	Hi,
	
	I have a very simple Layout based on LayoutSkeleton that
generates XML using the LoggingEvent values.  However; the exception
text always prints at the end of the XML.  Is there a way to turn this
off?
	
	My Format routine is as follows:
	
	                public override void Format(TextWriter writer,
LoggingEvent loggingEvent)
	                {
	                        writer.Write("<GSIEventLog>");
	                writer.Write("<Domain>" + loggingEvent.Domain +
"</Domain>");
	                    writer.Write("<ClassName>" +
loggingEvent.LocationInformation.ClassName + "/ClassName>");
	                writer.Write("<RenderedMessage>" +
loggingEvent.RenderedMessage + "</message>");
	                        writer.Write("<HostName>" +
loggingEvent.LookupProperty("log4net:HostName").ToString()  +
"</HostName>");
	                        writer.Write("<Identity>" +
loggingEvent.UserName + "</Identity>");
	                        writer.Write("<LoggerName>" +
loggingEvent.LoggerName + "</LoggerName>");
	                        writer.Write("<ThreadName>" +
loggingEvent.ThreadName + "</ThreadName>");
	                        writer.Write("<TimeStamp>" +
loggingEvent.TimeStamp + "</TimeStamp>");
	                        writer.Write("<EventId>" +
loggingEvent.LookupProperty("EventId").ToString() + "</EventId>");
	                        writer.Write("<Message2>" +
loggingEvent.LookupProperty("Message").ToString() + "</Message2>");
	                        writer.Write("<AppUser>" +
loggingEvent.LookupProperty("AppUser").ToString() + "</AppUser>");
	                        writer.Write("<SourceId>" +
loggingEvent.LookupProperty("SourceId").ToString() + "</SourceId>");
	                writer.Write("<ExMessage>" +
loggingEvent.ExceptionObject.Message + "</ExMessage>");
	                    writer.Write("<ExStackTrace>" +
loggingEvent.ExceptionObject.StackTrace + "</ExStackTrace>");
	                        writer.Write("</GSIEventLog>");
	
	                        writer.WriteLine();
	                }
	
	
	The output is:
	
<GSIEventLog><Domain>Test1.exe</Domain><ClassName>Test1.Form1/ClassName>
<RenderedMessage>message</message><HostName>jon-lt</HostName><Identity>G
SI\jfinley</Identity><LoggerName>Test1.Form1</LoggerName><ThreadName>251
6</ThreadName><TimeStamp>9/15/2005 3:00:04
PM</TimeStamp><EventId>1111</EventId><Message2>message</Message2><AppUse
r>jfinley-AppUser</AppUser><SourceId></SourceId><ExMessage>Object
reference not set to an instance of an object.</ExMessage><ExStackTrace>
at Test1.Form1.btnLog4NetTest_Click(Object sender, EventArgs e) in
C:\Development_NET\Test\Test1\Form1.vb:line
236</ExStackTrace></GSIEventLog>
	System.NullReferenceException: Object reference not set to an
instance of an object.
	   at Test1.Form1.btnLog4NetTest_Click(Object sender, EventArgs
e) in C:\Development_NET\Test\Test1\Form1.vb:line 236
	
	I would like the output to be:
	
<GSIEventLog><Domain>Test1.exe</Domain><ClassName>Test1.Form1/ClassName>
<RenderedMessage>message</message><HostName>jon-lt</HostName><Identity>G
SI\jfinley</Identity><LoggerName>Test1.Form1</LoggerName><ThreadName>251
6</ThreadName><TimeStamp>9/15/2005 3:00:04
PM</TimeStamp><EventId>1111</EventId><Message2>message</Message2><AppUse
r>jfinley-AppUser</AppUser><SourceId></SourceId><ExMessage>Object
reference not set to an instance of an object.</ExMessage><ExStackTrace>
at Test1.Form1.btnLog4NetTest_Click(Object sender, EventArgs e) in
C:\Development_NET\Test\Test1\Form1.vb:line
236</ExStackTrace></GSIEventLog>
	

	Thank you,

	Jon


Mime
View raw message