You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Paul Smith <Pa...@lawlex.com.au> on 2003/06/24 09:13:35 UTC
RE: cvs commit: jakarta-log4j-sandbox/src/java/org/apache/log4j/x
ml XMLLayout.java
Onlyl until the changes get merged in. I think the sandbox version of
XMLLayout includes some extra detail that isn't in the current log4j core.
If you're happy for me to review the differences and patch log4j, I can do
that. I'd prefer to merge as much back into the core if we can, but I'm
also warey of too much change.
cheers,
Paul
> -----Original Message-----
> From: Ceki Gülcü [mailto:ceki@qos.ch]
> Sent: Tuesday, 24 June 2003 5:16 PM
> To: Log4J Developers List
> Subject: Re: cvs commit:
> jakarta-log4j-sandbox/src/java/org/apache/log4j/xml XMLLayout.java
>
>
>
> Hi Paul,
>
> This commit was probably not necessary at all. Having
> duplicates lying
> around makes it very difficult to maintain the code. Now that
> both Scott
> and you have access to the log4j CVS
>
> At 02:45 AM 6/24/2003 +0000, you wrote:
> >psmith 2003/06/23 19:45:45
> >
> > Modified: src/java/org/apache/log4j/xml XMLLayout.java
> > Log:
> > Sandbox version of XMLLayout now conforms to the new
> Layout contract.
> >
> > Revision Changes Path
> > 1.3 +43
> > -51
> jakarta-log4j-sandbox/src/java/org/apache/log4j/xml/XMLLayout.java
> >
> > Index: XMLLayout.java
> >
> ===================================================================
> > RCS file:
> >
> /home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/xml/
> XMLLayout.java,v
> > retrieving revision 1.2
> > retrieving revision 1.3
> > diff -u -r1.2 -r1.3
> > --- XMLLayout.java 29 Apr 2003 16:21:30 -0000 1.2
> > +++ XMLLayout.java 24 Jun 2003 02:45:45 -0000 1.3
> > @@ -51,6 +51,8 @@
> > // Contributors: Mathias Bogaert
> > package org.apache.log4j.xml;
> >
> > +import java.io.IOException;
> > +import java.io.Writer;
> > import java.util.Iterator;
> > import java.util.Set;
> >
> > @@ -94,9 +96,6 @@
> > * @since 0.9.0
> > * */
> > public class XMLLayout extends Layout {
> > - private final int DEFAULT_SIZE = 256;
> > - private final int UPPER_LIMIT = 2048;
> > - private StringBuffer buf = new StringBuffer(DEFAULT_SIZE);
> > private boolean locationInfo = false;
> >
> > /**
> > @@ -128,108 +127,101 @@
> > /**
> > * Formats a {@link LoggingEvent} in conformance with
> the log4j.dtd.
> > * */
> > - public String format(LoggingEvent event) {
> > - // Reset working buffer. If the buffer is too large,
> then we need
> > a new
> > - // one in order to avoid the penalty of creating a
> large array.
> > - if (buf.capacity() > UPPER_LIMIT) {
> > - buf = new StringBuffer(DEFAULT_SIZE);
> > - } else {
> > - buf.setLength(0);
> > - }
> > + public void format(Writer output, LoggingEvent event)
> > + throws IOException {
> >
> > // We yield to the \r\n heresy.
> > - buf.append("<log4j:event logger=\"");
> > - buf.append(event.getLoggerName());
> > - buf.append("\" level=\"");
> > - buf.append(event.getLevel());
> > - buf.append("\" thread=\"");
> > - buf.append(event.getThreadName());
> > - buf.append("\" timestamp=\"");
> > - buf.append(event.timeStamp);
> > - buf.append("\">\r\n");
> > + output.write("<log4j:event logger=\"");
> > + output.write(event.getLoggerName());
> > + output.write("\" level=\"");
> > + output.write(String.valueOf(event.getLevel()));
> > + output.write("\" thread=\"");
> > + output.write(event.getThreadName());
> > + output.write("\" timestamp=\"");
> > + output.write(String.valueOf(event.timeStamp));
> > + output.write("\">\r\n");
> >
> > - buf.append("<log4j:message><![CDATA[");
> > + output.write("<log4j:message><![CDATA[");
> >
> > // Append the rendered message. Also make sure to escape any
> > // existing CDATA sections.
> > - Transform.appendEscapingCDATA(buf,
> event.getRenderedMessage());
> > - buf.append("]]></log4j:message>\r\n");
> > + Transform.appendEscapingCDATA(output,
> event.getRenderedMessage());
> > + output.write("]]></log4j:message>\r\n");
> >
> > String ndc = event.getNDC();
> >
> > if (ndc != null) {
> > - buf.append("<log4j:NDC><![CDATA[");
> > - buf.append(ndc);
> > - buf.append("]]></log4j:NDC>\r\n");
> > + output.write("<log4j:NDC><![CDATA[");
> > + output.write(ndc);
> > + output.write("]]></log4j:NDC>\r\n");
> > }
> >
> > Set mdcSet = event.getMDCKeySet();
> >
> > if ((mdcSet != null) && (mdcSet.size() > 0)) {
> > - buf.append("<log4j:MDC>");
> > + output.write("<log4j:MDC>");
> >
> > Iterator iter = mdcSet.iterator();
> >
> > while (iter.hasNext()) {
> > String propName = (String) iter.next();
> > - buf.append("<log4j:data name=\"" + propName);
> > + output.write("<log4j:data name=\"" + propName);
> >
> > String propValue = (String) event.getMDC(propName);
> > - buf.append("\" value=\"" + propValue);
> > - buf.append("\"/>\r\n");
> > + output.write("\" value=\"" + propValue);
> > + output.write("\"/>\r\n");
> > }
> >
> > - buf.append("</log4j:MDC>\r\n");
> > + output.write("</log4j:MDC>\r\n");
> > }
> >
> > String[] s = event.getThrowableStrRep();
> >
> > if (s != null) {
> > - buf.append("<log4j:throwable><![CDATA[");
> > + output.write("<log4j:throwable><![CDATA[");
> >
> > for (int i = 0; i < s.length; i++) {
> > - buf.append(s[i]);
> > - buf.append("\r\n");
> > + output.write(s[i]);
> > + output.write("\r\n");
> > }
> >
> > - buf.append("]]></log4j:throwable>\r\n");
> > + output.write("]]></log4j:throwable>\r\n");
> > }
> >
> > if (locationInfo) {
> > LocationInfo locationInfo = event.getLocationInformation();
> > - buf.append("<log4j:locationInfo class=\"");
> > - buf.append(locationInfo.getClassName());
> > - buf.append("\" method=\"");
> > -
> buf.append(Transform.escapeTags(locationInfo.getMethodName()));
> > - buf.append("\" file=\"");
> > - buf.append(locationInfo.getFileName());
> > - buf.append("\" line=\"");
> > - buf.append(locationInfo.getLineNumber());
> > - buf.append("\"/>\r\n");
> > + output.write("<log4j:locationInfo class=\"");
> > + output.write(locationInfo.getClassName());
> > + output.write("\" method=\"");
> > + Transform.escapeTags(locationInfo.getMethodName(), output);
> > + output.write("\" file=\"");
> > + output.write(locationInfo.getFileName());
> > + output.write("\" line=\"");
> > + output.write(locationInfo.getLineNumber());
> > + output.write("\"/>\r\n");
> > }
> >
> > Set propertySet = event.getPropertyKeySet();
> >
> > if ((propertySet != null) && (propertySet.size() > 0)) {
> > - buf.append("<log4j:properties>");
> > + output.write("<log4j:properties>");
> >
> > Iterator propIter = propertySet.iterator();
> >
> > while (propIter.hasNext()) {
> > String propName = (String) propIter.next();
> > - buf.append("<log4j:data name=\"" + propName);
> > + output.write("<log4j:data name=\"" + propName);
> >
> > String propValue = (String) event.getProperty(propName);
> > - buf.append("\" value=\"" + propValue);
> > - buf.append("\"/>\r\n");
> > + output.write("\" value=\"" + propValue);
> > + output.write("\"/>\r\n");
> > }
> >
> > - buf.append("</log4j:properties>\r\n");
> > + output.write("</log4j:properties>\r\n");
> > }
> >
> > - buf.append("</log4j:event>\r\n\r\n");
> > + output.write("</log4j:event>\r\n\r\n");
> >
> > - return buf.toString();
> > }
> >
> > /**
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>
> --
> Ceki For log4j documentation consider "The complete log4j manual"
> ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org
RE: cvs commit:
jakarta-log4j-sandbox/src/java/org/apache/log4j/x ml XMLLayout.java
Posted by Ceki Gülcü <ce...@qos.ch>.
Oh, right. I failed to mention that the version of XMLLayout in
log4j-proper already includes the changes from the sandbox. Entirely
my fault and sorry for the confusion.
At 05:13 PM 6/24/2003 +1000, you wrote:
>Onlyl until the changes get merged in. I think the sandbox version of
>XMLLayout includes some extra detail that isn't in the current log4j core.
>
>If you're happy for me to review the differences and patch log4j, I can do
>that. I'd prefer to merge as much back into the core if we can, but I'm
>also warey of too much change.
I think the overlap between log4j-proper and sandbox consists of
XMLLayout, chainsaw, some files in o.a.l.net, o.a.l.plugins, and
o.a.l.filter. The changes to LoggingEvent, and ThrowableInfo have been
already merged with log4j-proper sometime ago.
The more we wait the harder it will get to move these files, no?
Mark, what do you think?
>cheers,
>
>Paul
--
Ceki For log4j documentation consider "The complete log4j manual"
ISBN: 2970036908 http://www.qos.ch/shop/products/clm_t.jsp
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org