1) why not use something like:
<call path="/categoryset/category/appender/" target="..."/>
to process every appender ? You may have to do this separately from
setting the name.
2) Your <replace> doesn't work. Can you post how you're using it (the
one-liner <replace>), pls ?
Brian
On 11/08/2009 14:03, soumya sree kullu wrote:
Hi ,
I am using xml task for dynamically adding log4j appenders and
categories in my web.xml ,
My solution goes like this -
my web.xml is
----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<root>
<priority value="fatal"/>
</root>
</log4j:configuration>
-------------------------------------------
I want to add the appenders and categories to the above xml file.
hence I used xml task in my ant build.xml file ,
by reading the appenders and category names through a configuration
file like this -
Build-configuration file
-----------------------------------
<?xml version="1.0"?>
<categoryset>
<category >
<testname>Category1</testname>
<appender>A1</appender>
<appender>B1</appender>
<appender>C1</appender>
</category>
<category >
<testname>Category2</testname>
<appender>a2</appender>
<appender>b2</appender>
<appender>c2</appender>
</category>
<appenderfilesize>
<testname>a2</testname>
<MaxFileSize>10000KB</MaxFileSize >
</appenderfilesize>
</categoryset>
-------------------------------------
In the ant build.xml file I use xml task to add appenders and
categories that adds to my web.xml , like this-
In the ant build.xml file
--------------------------------
<target name="main" depends="testprg"/>
<property name="web.xmlfile" value="C:/test/web.xml" />
<target name="testprg">
<xmltask source="build-configuration.xml">
<call path="/categoryset/category" target="roottest">
<param name="name" path="testname/text()" />
<param name="appender1" path="appender[1]/text()" />
<param name="appender2" path="appender[2]/text()" />
<param name="appender3" path="appender[3]/text()" />
</call>
<call path="/categoryset/catego...@testname]/appender"
target="compile-and-release">
<param name="build" path="text()"/>
</call>
</xmltask>
</target>
<target name="roottest" >
<echo>Building Category ${name}</echo>
<echo>Appender ${appender1}</echo>
<echo>Appender ${appender2}</echo>
<echo>Appender ${appender3}</echo>
<xmltask source="${web.xmlfile}" dest="${web.xmlfile}"
failWithoutMatch="true">
<insert path="/log4j:configuration/root" position="after">
<![CDATA[ <category name="${name}">
<priority value="debug" />
<appender-ref ref="${appender1}" />
<appender-ref ref="${appender2}" />
<appender-ref ref="${appender3}" />
</category> ]]>
</insert>
</xmltask>
</target>
<target name="compile-and-release">
<xmltask source="${web.xmlfile}" dest="${web.xmlfile}"
failWithoutMatch="true">
<insert path="/log4j:configuration/root" position="after">
<![CDATA[
<appender name="${build}" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="uan.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="25000KB" />
<param name="MaxBackupIndex" value="5"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1}
[%t][%x]: %m%n"/>
</layout>
</appender>
]]>
</insert>
</xmltask>
-----------------------------------------------------
The above solution works fine until i know the number of appenders, but -
I dont want to mention the array notation of appenders in xml task ,
ie.
<call path="/categoryset/category" target="roottest">
<param name="name" path="testname/text()" />
<param name="appender1" path="appender[1]/text()" />
<param name="appender2" path="appender[2]/text()" />
<param name="appender3" path="appender[3]/text()" />
</call>
as the appenders are not static , they may increase or decrease
under a category. I want to implement some looping kind of mechanism
which actually reads the category and then loop through the appenders
which creates nodes under category like - and should get the same
output into web.xml like what the solution does now...i.e.
<category name="Category2">
<priority value="debug"/>
<appender-ref ref="a2"/>
<appender-ref ref="b2"/>
<appender-ref ref="c2"/>
</category>
Is there a way ?
2 ) I facing some problems in replacign the value in the xml node..
Using build-configuration file . I read the max-file size but it
doesnt work
------------------------------------
<appenderfilesize>
<testname>a2</testname>
<MaxFileSize>10000KB</MaxFileSize >
</appenderfilesize>
--------------------------
<appender class="org.apache.log4j.RollingFileAppender" name="a2">
<param name="File" value="uan.log"/>
<param name="Append" value="true"/>
<param name="MaxFileSize" value="*25000KB*"/>
<param name="MaxBackupIndex" value="5"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1}
[%t][%x]: %m%n"/>
</layout>
</appender>
The value has to be changed to 10000KB , i was using replace xmltask
but didnt succeed..
can anyone please help me out in solving the issues ... ??will be so
thankful to them ..
soumya
------------------------------------------------------------------------
Love Cricket? Check out live scores, photos, video highlights and
more. Click here
<http://in.rd.yahoo.com/tagline_cricket_2/*http://cricket.yahoo.com>.
--
Brian Agnew http://www.oopsconsultancy.com
OOPS Consultancy Ltd
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users