Bug 37560 - Does not handle embedded xml correctly
Summary: Does not handle embedded xml correctly
Alias: None
Product: Log4j - Now in Jira
Classification: Unclassified
Component: Layout (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal
Target Milestone: ---
Assignee: log4j-dev
Depends on:
Reported: 2005-11-18 20:58 UTC by Richard Hansen
Modified: 2007-08-22 16:56 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Richard Hansen 2005-11-18 20:58:28 UTC
Chainsaw would not parse a file that had xml embedded in an NDC. Here are the
error messages :

Parsing error on line 345 and column 418
The element type "log4j:NDC" must be terminated by the matching end-tag

Here is the event:

<log4j:event logger="com.tlr.bis.online.charges.jaxprc.trmr.StandardTRMRHandler"
timestamp="1132342098624" level="DEBUG" thread="WebContainer : 0">
value "12-31-2005" has an invalid format for
Comment 1 Curt Arnold 2006-08-31 21:03:53 UTC
Not Chainsaw's fault.  The serializer (I assume that log4j's XMLLayout) used to write the sample document 
is naive and just dropped the NDC content into a CDATA section.  Unfortunately, the termination of the 
CDATA section within the NDC content (the ]]>) prematurely ended the CDATA section added by the 
serialization.  You can't nest CDATA sections.

Solutions would be to use a real XML serializer (like that provided by Xerces) or to make the log4j 
serializer smarter and not depend on CDATA sections (that is, it would convert <, > and & to &lt;, &gt; and 
&amp; and likely convert characters with code points greater than 127 to &#NNN; 
Comment 2 Curt Arnold 2007-08-22 16:24:26 UTC
I believe that XMLLayout has been modified to detect embedded CDATA sections.  If not, you can use 
XSLTLayout in the extras companion.  Marking as fixed.  Reopen if you still see the problem in 1.2.15.
Comment 3 Curt Arnold 2007-08-22 16:56:30 UTC
Spoke too soon.  XMLLayout did not call appendEscapingCDATA on NDC or throwable content.  Added new 
unit tests and fixed XMLLayout in rev 568774.  XSLTLayout handled situation properly, but added same 
tests to its test suite in 568775.