logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roy Chastain" <...@roychastain.org>
Subject RE: Did the exception format change from XML -> string in 1.2.11?
Date Fri, 16 Dec 2011 21:44:52 GMT
Todd,
The <> that you are getting are because the class/method name has <> in
it.  It has these brackets because it is either a .NET Framework generic
class or an anonymous delegate/lambda expression.

Stephan said that he looked at the code and he believes that IRawLayout
in AdoNetAppender will correctly escape the <> as &lt; &gt;.

Can you confirm what layout you are using?

----------------------------------------------------------------------
Roy Chastain




-----Original Message-----
From: Todd [mailto:todd_beaulieu@yahoo.com] 
Sent: Friday, December 16, 2011 11:54
To: Log4NET User
Subject: Re: Did the exception format change from XML -> string in
1.2.11?

I'm back on this project and still struggling. I've spent HOURS trying
to figure this out.
 
Perhaps I'm going about this all wrong, I don't know. I'd be
appreciative if someone could tell me if I'm off base here, or what.
 
Goal:
 
I want to record the entire exception (stack trace is the mother load,
of course) in my database. I'm using a stored proc to insert the event
and that sproc has a Details parameter which is XML. 
 
 
What I've tried:
 
I've been able to specify a pattern that has the required XML wrapper
nodes (and no actual insertions from log4net) and that makes it into the
db. This is the format that I need to adhere to support the dashboard
that we use to monitor for problems.
 
<layout type="log4net.Layout.PatternLayout">
  <conversionPattern value="&lt;DETAILS&gt;
&lt;EXCEPTION&gt;&lt;/EXCEPTION&gt; &lt;/DETAILS&gt;" /> </layout>

So this simply inserts:
 
<DETAILS>
  <EXCEPTION />
</DETAILS>
 
Next step, I tried to insert the exception itself by include
"%exception" in the above pattern at the appropriate place. 
 
I'm breakpointing on virtual protected void SendBuffer(IDbTransaction
dbTran, LoggingEvent[] events) just before it attempts to execute the
command. The exception is not being escaped. It contains <> in the
stacktrace, which blow up the XML. There may be other characters in
there as well, but hopefully the solution will resolve everything.
 
I tried the ExceptionLayout pattern. It doesn't escape the stacktrack.
 
I tried the above pattern with the XmlLayout and, even though I didn't
embed any field patterns, still got the exception, but wrapped in
<log4net:event> nodes. The inner text was still not escaped, and thus
failed.
 
So am I missing something obvious? Has anyone ever logged exceptions
using an XML data type? 
 
Thank you for any guidance!

From: Stefan Bodewig <bodewig@apache.org>
To: Log4NET User <log4net-user@logging.apache.org>
Sent: Friday, October 21, 2011 6:20 AM
Subject: Re: Did the exception format change from XML -> string in
1.2.11?

On 2011-10-19, Todd wrote:

> I grabbed the latest version and now I can't log any exceptions, 
> APPARENTLY because the format changed. My sproc expects the xml 
> payload, but I now seem to be getting a formatted string. The 
> stacktrace in the string can contain "<>", which causes the call to 
> the sproc to fail. (it's expecting xml data, but only sees xml 
> brackets inside)

The actual formatting happens via the IRawLayout in AdoNetAppender (this
is what I assume you are using).  What does you configuration for this
look like?

I quickly glanced over the code changes in AdoNetAppender and the
related layout and converter classes but don't see any change that would
explain your findings.  Of course I may be missing something.

Stefan




Mime
View raw message