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 Piyush Kar <ka...@yahoo.com> on 2004/03/25 16:32:27 UTC

Formatting XMLLayout

Hi

I am planning to use MDC with Log4J and use it with
the XMLLayout so that the MDC information (which in my
case is the host name) is recorded with every log
message . 

I was able to successfully use MDC with the
PatternLayout by specifying it as 

 <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern"
value="%X{remotehost} %d{DATE} %-5p %-15c{1}: %m%n"/>
      </layout>

However I am not able to do the same using XMLLayout .
I browsed the net and could not findy any examples as
to doing something similar (i.e being able to use the
equivalent of conversionpattern with XMLLayout ) . 

Please help as our project deadline is coming closer
and for last 5 days i have had no luck with the same .
The Log4J docs also dont have any example as to how to
format the XMLLayout output .

Any help would be cool !!

Thanks in advance

Kar

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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


Re: Formatting XMLLayout

Posted by Paul Smith <pa...@lawlex.com.au>.
> Do you mean that XMLLayout thats accepts MDC input is
> available from CVS . I currently have version 1.2.8 so
> dont know if that suports MDC or not .
> 

Yes, it means to have the feature you seem to need, you will need to
download the CVS module from the apache cvs server and build the jar
using ant.  

The HEAD of this cvs module is notionally the log4j1.3 version, but we
haven't reached the alpha phase yet, so please use it at your own risk.

> Secondly can u let me know as to what needs to be done
> in order to be able to use MDC with XMLLayout -- can I
> see a log4j.xml config explaining the same if
> available .
> 

Nothing to do but choose to use the XMLLayout if you decide to use the
pre-alpha-1.3 version built from cvs. XMLLayout will output the MDC
values according to the org.apache.log4j.xml.log4j.dtd file.

> Thirdly is there any way I can include a pattern as in
> the PatternLayout to spit out teh XML message ?? I
> mean basically I want to show the hostname and time of
> log message in the XML output and am kinda in a fix as
> to if it can be done.
> 

It MIGHT be possible...  You'd have to do some PatternLayout trickery.
Might be easier to try downloading the log4j cvs and build it and try it
first.

Paul




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


Re: Formatting XMLLayout

Posted by Piyush Kar <ka...@yahoo.com>.
Paul

thanks for the info.

when you mean >
> If you REALLY need this, it's already available from
> the CVS HEAD.

Do you mean that XMLLayout thats accepts MDC input is
available from CVS . I currently have version 1.2.8 so
dont know if that suports MDC or not .

Secondly can u let me know as to what needs to be done
in order to be able to use MDC with XMLLayout -- can I
see a log4j.xml config explaining the same if
available .

Thirdly is there any way I can include a pattern as in
the PatternLayout to spit out teh XML message ?? I
mean basically I want to show the hostname and time of
log message in the XML output and am kinda in a fix as
to if it can be done.

Once again thanks for the input .

- Kar
--- Paul Smith <pa...@lawlex.com.au> wrote:
> > However I am not able to do the same using
> XMLLayout .
> > I browsed the net and could not findy any examples
> as
> > to doing something similar (i.e being able to use
> the
> > equivalent of conversionpattern with XMLLayout ) .
> 
> > 
> > Please help as our project deadline is coming
> closer
> > and for last 5 days i have had no luck with the
> same .
> > The Log4J docs also dont have any example as to
> how to
> > format the XMLLayout output .
> 
> If you REALLY need this, it's already available from
> the CVS HEAD.   You
> can't format XMLLayout.  The XML IS the format...
> 
> You will have to weigh up whether the feature is
> worth going with a
> non-release version of log4j though. Worth trying it
> out though.
> 
> cheers,
> 
> Paul Smith
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail:
> log4j-user-help@logging.apache.org
> 


__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

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


Re: Formatting XMLLayout

Posted by Paul Smith <pa...@lawlex.com.au>.
> However I am not able to do the same using XMLLayout .
> I browsed the net and could not findy any examples as
> to doing something similar (i.e being able to use the
> equivalent of conversionpattern with XMLLayout ) . 
> 
> Please help as our project deadline is coming closer
> and for last 5 days i have had no luck with the same .
> The Log4J docs also dont have any example as to how to
> format the XMLLayout output .

If you REALLY need this, it's already available from the CVS HEAD.   You
can't format XMLLayout.  The XML IS the format...

You will have to weigh up whether the feature is worth going with a
non-release version of log4j though. Worth trying it out though.

cheers,

Paul Smith



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