-
Bug
-
Resolution: Unresolved
-
P4
-
1.4.0, 5.0
-
Fix Understood
-
x86
-
windows_nt, windows_2000
Name: nt126004 Date: 01/28/2002
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT Ver 4.0 SP 6
A DESCRIPTION OF THE PROBLEM :
When using the new looging feature, and appending to a XML-
Logfile, the Header and Footer gets written each time the
file is reopened.
This causes a not well formed error.
When appending, records must be merged.
Just compile the testcase and execute. A
new XML Logfile gets created called 'logfile.xml'.
Open the logfile and check for the 2 entries.
Everything is OK.
Execute the Testcase a second time. Because the 'append-flag' is set to 'true', the old 'logfile.xml' doesn't
get deleted, all new entries get appended. when you
open the 'logfile.xml' now, and check for well-
formedness, you will receive an error, because the xml
file isn't well formed anymore. Each time you start the
TestCase, a whole XML-File (including Header and
Footer) is appended to the old File.
The right way this must be done, is to merge the new
entries between the </record> tag of the last entry and
the </log> tag.
Example:
<?xml version="1.0" encoding="windows-1252" standalone="no"?
>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2002-01-09T09:26:31</date>
<millis>1010564791613</millis>
<sequence>0</sequence>
<logger>build.generate.antxml</logger>
<level>FINE</level>
<class>Test</class>
<method>main</method>
<thread>10</thread>
<message>.....message.......</message>
</record>
</log>
<?xml version="1.0" encoding="windows-1252" standalone="no"?
>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2002-01-09T09:26:36</date>
<millis>1010564796711</millis>
<sequence>0</sequence>
<logger>build.generate.antxml</logger>
<level>FINE</level>
<class>Test</class>
<method>main</method>
<thread>10</thread>
<message>.....message.....</message>
</record>
</log>
This bug can be reproduced always.
---------- BEGIN SOURCE --------
import java.util.logging.*;
/**
* Short desc.
*<br>
* long description
*
*/
public class TestCase {
public static void main( String[] args) {
try {
FileHandler fh = new FileHandler("logfile.xml",true);
XMLFormatter xmlf = new XMLFormatter();
fh.setFormatter(xmlf);
Logger logger = Logger.getLogger("test.test1.test2");
logger.addHandler(fh);
logger.setLevel(Level.ALL);
logger.warning("that is a test log message -- Level WARNING");
logger.info("that is a second test log message -- Level WARNING");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
(Review ID: 138077)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT Ver 4.0 SP 6
A DESCRIPTION OF THE PROBLEM :
When using the new looging feature, and appending to a XML-
Logfile, the Header and Footer gets written each time the
file is reopened.
This causes a not well formed error.
When appending, records must be merged.
Just compile the testcase and execute. A
new XML Logfile gets created called 'logfile.xml'.
Open the logfile and check for the 2 entries.
Everything is OK.
Execute the Testcase a second time. Because the 'append-flag' is set to 'true', the old 'logfile.xml' doesn't
get deleted, all new entries get appended. when you
open the 'logfile.xml' now, and check for well-
formedness, you will receive an error, because the xml
file isn't well formed anymore. Each time you start the
TestCase, a whole XML-File (including Header and
Footer) is appended to the old File.
The right way this must be done, is to merge the new
entries between the </record> tag of the last entry and
the </log> tag.
Example:
<?xml version="1.0" encoding="windows-1252" standalone="no"?
>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2002-01-09T09:26:31</date>
<millis>1010564791613</millis>
<sequence>0</sequence>
<logger>build.generate.antxml</logger>
<level>FINE</level>
<class>Test</class>
<method>main</method>
<thread>10</thread>
<message>.....message.......</message>
</record>
</log>
<?xml version="1.0" encoding="windows-1252" standalone="no"?
>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
<date>2002-01-09T09:26:36</date>
<millis>1010564796711</millis>
<sequence>0</sequence>
<logger>build.generate.antxml</logger>
<level>FINE</level>
<class>Test</class>
<method>main</method>
<thread>10</thread>
<message>.....message.....</message>
</record>
</log>
This bug can be reproduced always.
---------- BEGIN SOURCE --------
import java.util.logging.*;
/**
* Short desc.
*<br>
* long description
*
*/
public class TestCase {
public static void main( String[] args) {
try {
FileHandler fh = new FileHandler("logfile.xml",true);
XMLFormatter xmlf = new XMLFormatter();
fh.setFormatter(xmlf);
Logger logger = Logger.getLogger("test.test1.test2");
logger.addHandler(fh);
logger.setLevel(Level.ALL);
logger.warning("that is a test log message -- Level WARNING");
logger.info("that is a second test log message -- Level WARNING");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
(Review ID: 138077)
======================================================================