You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Madduri, Murthy" <Mu...@fnf.com> on 2007/03/01 00:33:03 UTC

Using XMLLayout..

Hi,

 

As a part of our J2EE application, we need to build a custom Layout for
the logging event. The generated log file is expected to be very large.

The custom layout need not to conform to any DTD, but, needs to be a
well-formed XML with the root element.

I am using XPath expression on the XML string to get the proper output.

 

Right now, I have extended the Layout class to generate the output using
brute StringBuffer append method.

When I am trying to transform this file (which is not a well-formed
XML), the transformer complains that it is missing the root element.

Is it a better idea to tweak the XMLLayout to fit-in the custom content?

 

Here is a sample of the content that is in the log file:

<MSG><HOST>myHost</Host><STATUS>Response</STATUS></MSG> 

<MSG><HOST>myHost1</Host><STATUS>FAIL</STATUS></MSG>

<MSG><HOST>myHost2</Host><STATUS>Unknown</STATUS></MSG>

 

If I can get this with a root element, the transformer works fine.

 

<ROOT>

<MSG><HOST>myHost</Host><STATUS>Response</STATUS></MSG> 

<MSG><HOST>myHost1</Host><STATUS>FAIL</STATUS></MSG>

<MSG><HOST>myHost2</Host><STATUS>Unknown</STATUS></MSG>

</ROOT>

 

I appreciate any help on this.

 

Thanks & Regards,

Murthy Madduri

*(770)263-1231

*Email:murthy.madduri@fnf.com <ma...@fnf.com> 

 

 


Re: Using XMLLayout..

Posted by Curt Arnold <ca...@apache.org>.
 From a previous time the question was asked:


On Jan 11, 2007, at 4:27 PM, Curt Arnold wrote:
>
> log4j doesn't actually produce an XML document since an XML  
> document can only have one element.  log4j produces an XML parsed  
> entity (in this case a sequence of elements) that can be referenced  
> in an XML document and it is assumed that the containing document  
> would declare the namespace prefix.  To process the output of log4j  
> by XSLT, you would need to create a small XML document that  
> includes the log file and then process the XML document using XSLT.
>
> Your XML document would look like:
>
> <!DOCTYPE mydocument [
> <!ENTITY logfile SYSTEM 'logger.xml'>
> ]>
> <mydocument xmlns:log4j='http://jakarta.apache.org/log4j/'>
> &logfile;
> </mydocument>
>


Question comes up enough that there should be a FAQ on it and check  
that the documentation mentions it.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Using XMLLayout..

Posted by James Stauffer <st...@gmail.com>.
Since the file is continuously changed it wouldn't be possible to have
a root element unless it is added as it is rolled.

On 2/28/07, Madduri, Murthy <Mu...@fnf.com> wrote:
> Hi,
>
>
>
> As a part of our J2EE application, we need to build a custom Layout for
> the logging event. The generated log file is expected to be very large.
>
> The custom layout need not to conform to any DTD, but, needs to be a
> well-formed XML with the root element.
>
> I am using XPath expression on the XML string to get the proper output.
>
>
>
> Right now, I have extended the Layout class to generate the output using
> brute StringBuffer append method.
>
> When I am trying to transform this file (which is not a well-formed
> XML), the transformer complains that it is missing the root element.
>
> Is it a better idea to tweak the XMLLayout to fit-in the custom content?
>
>
>
> Here is a sample of the content that is in the log file:
>
> <MSG><HOST>myHost</Host><STATUS>Response</STATUS></MSG>
>
> <MSG><HOST>myHost1</Host><STATUS>FAIL</STATUS></MSG>
>
> <MSG><HOST>myHost2</Host><STATUS>Unknown</STATUS></MSG>
>
>
>
> If I can get this with a root element, the transformer works fine.
>
>
>
> <ROOT>
>
> <MSG><HOST>myHost</Host><STATUS>Response</STATUS></MSG>
>
> <MSG><HOST>myHost1</Host><STATUS>FAIL</STATUS></MSG>
>
> <MSG><HOST>myHost2</Host><STATUS>Unknown</STATUS></MSG>
>
> </ROOT>
>
>
>
> I appreciate any help on this.
>
>
>
> Thanks & Regards,
>
> Murthy Madduri
>
> *(770)263-1231
>
> *Email:murthy.madduri@fnf.com <ma...@fnf.com>
>
>
>
>
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org