Issue Details (XML | Word | Printable)

Key: LOG4NET-34
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Unassigned
Reporter: Ron Grabowski
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Log4net

Allow xml config values to be set via XmlNodeType.CDATA or XmlNodeType.Text rather than just value="foo"

Created: 15/Jun/05 10:15 PM   Updated: 17/Jun/05 03:01 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.2.10

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works XmlHierarchyConfigurator.cs.patch 2005-06-15 10:17 PM Ron Grabowski 1 kB

Resolution Date: 17/Jun/05 03:01 AM


 Description  « Hide
Currently values for xml config nodes must be passed in via the value attribute:

 <conversionPattern value="%5p %d{yyyy-MM-dd hh:mm:ss tt} (%c:%L) - %m%n" />

Why isn't this syntax supported?

 <conversionPattern>%5p %d{yyyy-MM-dd hh:mm:ss tt} (%c:%L) - %m%n</conversionPattern>

If the above syntax were supported, a possible solution to this question:

 http://www.mail-archive.com/log4net-user%40logging.apache.org/msg01791.html

would be:

 <conversionPattern>
  <![CDATA[<header>%n <date>%d</date>%n <user>%u</user>%n <info>%m</info>%n</header>%n]]>
 </conversionPattern>

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #312294 Wed Jun 15 17:54:21 UTC 2005 nicko Applied patch for LOG4NET-34 Allow xml config values to be set via XmlNodeType.CDATA or XmlNodeType.Text rather than just value=xxx
Files Changed
MODIFY /logging/log4net/trunk/src/Repository/Hierarchy/XmlHierarchyConfigurator.cs

Ron Grabowski added a comment - 15/Jun/05 10:18 PM
If a value attribute is not found, loop through the child node to find the first CDATA or Text node and use its InnerText as the value.

Ron Grabowski made changes - 15/Jun/05 10:18 PM
Field Original Value New Value
Attachment XmlHierarchyConfigurator.cs.patch [ 12310769 ]
Nicko Cadell added a comment - 16/Jun/05 02:13 AM
It is possible to embed < and > in the current attribute value, just escape using &lt; and &gt;

I will have a look at the impact of your patch and see if it can be easily integraged - on first look it looks ok. I think we should probably concatenate any text or CDATA node text rather than taking the last one, but apart from that it looks ok.

Ron Grabowski added a comment - 16/Jun/05 02:39 AM
The code actually takes the first text or CDATA. That allows a comment to come before the text.

Another general benefit of being able to use CDATA is that you don't have squeeze potentially long marksup all on one line:

<conversionPattern>
 <!-- Hello World -->
<![CDATA[
<header>
 <date>
  <hour>
    %d{h}
  </hour>
 </date>
 <user>
 %u
 </user>
 <info>
 %m
 </info>
</header>
]]>
</conversionPattern>

I quicklyt tried inserting tabs into the layout using \t, \\t, and '\t' but they always rendered as a literal. I didn't see a %tab pattern or a %space{5} pattern.

If the text were concatenated, would this appear on one line in the output file?

<conversionPattern>
 <!-- this text is ignored -->
 <![CDATA[%m ]]>
 <!-- this text is ignored -->
 <![CDATA[%d ]]>
 <!-- this text is ignored -->
 <![CDATA[%n ]]>
</conversionPattern>

It looks a little messy but I can think of some cases where it could be useful. Especially with describing custom patterns.

Nicko Cadell added a comment - 17/Jun/05 03:00 AM
Multiple CDATA sections will be concatenated together on a single line. Empty text nodes will be ignored (by the parser).

To embed a tab in the config file you need to use the XML numberic character reference &#9;

Nicko Cadell added a comment - 17/Jun/05 03:01 AM
I have applied the patch with mods and all is well

Nicko Cadell made changes - 17/Jun/05 03:01 AM
Fix Version/s 1.2.10 [ 11128 ]
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]