Author: psmith Date: Fri Nov 2 22:16:19 2007 New Revision: 591552 URL: http://svn.apache.org/viewvc?rev=591552&view=rev Log: Bug 43736 applied patch provided by Curt with extraction to a constant to indicate that XMLDecoder only deals with UTF-8 encoded log files.
Previously the system default encoding was being used to read in the XML file, even though a header DOCTYPE pre-amble was added indicating the file was in UTF-8 encoding. This is pretty much a stop gap fix for the time being. At the moment there is no way in Chainsaw to specify the encoding of the file about to be opened. Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java Modified: logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java URL: http://svn.apache.org/viewvc/logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java?rev=591552&r1=591551&r2=591552&view=diff ============================================================================== --- logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java (original) +++ logging/log4j/companions/receivers/trunk/src/main/java/org/apache/log4j/xml/XMLDecoder.java Fri Nov 2 22:16:19 2007 @@ -37,9 +37,9 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.spi.Decoder; +import org.apache.log4j.spi.LocationInfo; import org.apache.log4j.spi.LoggingEvent; import org.apache.log4j.spi.ThrowableInformation; -import org.apache.log4j.spi.LocationInfo; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -56,17 +56,23 @@ * NOTE: Only a single LoggingEvent is returned from the decode method * even though the DTD supports multiple events nested in an eventSet. * - * + * NOTE: This class has been created on the assumption that all XML log files + * are encoding in UTF-8 encoding. There is no current support for any other + * encoding format at this time. + * * @author Scott Deboy ([EMAIL PROTECTED]) * @author Paul Smith ([EMAIL PROTECTED]) * */ public class XMLDecoder implements Decoder { + + private static final String ENCODING = "UTF-8"; + /** * Document prolog. */ private static final String BEGINPART = - "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + "<?xml version=\"1.0\" encoding=\"" + ENCODING + "\" ?>" + "<!DOCTYPE log4j:eventSet SYSTEM \"http://localhost/log4j.dtd\">" + "<log4j:eventSet version=\"1.2\" " + "xmlns:log4j=\"http://jakarta.apache.org/log4j/\">"; @@ -183,9 +189,9 @@ if (owner != null) { reader = new LineNumberReader(new InputStreamReader( new ProgressMonitorInputStream(owner, - "Loading " + url , url.openStream()))); + "Loading " + url , url.openStream()), ENCODING)); } else { - reader = new LineNumberReader(new InputStreamReader(url.openStream())); + reader = new LineNumberReader(new InputStreamReader(url.openStream(), ENCODING)); } Vector v = new Vector(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]