-
Enhancement
-
Resolution: Future Project
-
P4
-
None
-
6
-
x86
-
windows_xp
A DESCRIPTION OF THE REQUEST :
The XMLFormatter log formatter doesn't print cause exceptions of exceptions thrown in log records.
This report was originally filed as Incident Review ID 323362, but contact with the engineer in charge of it stopped abruptly, so it must have been thrown out or lost somehow.
I was asked in that report to provide a full test case. I have done so.
JUSTIFICATION :
Chained exceptions were added to Java in release 1.4.0. The log formatters should support them.
ACTUAL -
Here is the test case. It creates a file log-output.xml. You can see
that there is no mention of the IllegalArgumentException in the log
file, even though it was passed to the RuntimeException as the cause.
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.XMLFormatter;
public class XMLFormatterDemo {
public static void main(String[] args) {
Logger l = Logger.getAnonymousLogger();
l.setLevel(Level.ALL);
Handler handler;
try {
handler = new FileHandler("log-output.xml");
} catch (IOException e) {
e.printStackTrace();
return;
}
handler.setFormatter(new XMLFormatter());
l.addHandler(handler);
// log an exception
IllegalArgumentException cause = new
IllegalArgumentException("bad argument");
l.log(Level.SEVERE, "Exception", new RuntimeException("Some
error", cause));
}
}
---------- END SOURCE ----------
###@###.### 2005-05-06 05:27:59 GMT
The XMLFormatter log formatter doesn't print cause exceptions of exceptions thrown in log records.
This report was originally filed as Incident Review ID 323362, but contact with the engineer in charge of it stopped abruptly, so it must have been thrown out or lost somehow.
I was asked in that report to provide a full test case. I have done so.
JUSTIFICATION :
Chained exceptions were added to Java in release 1.4.0. The log formatters should support them.
ACTUAL -
Here is the test case. It creates a file log-output.xml. You can see
that there is no mention of the IllegalArgumentException in the log
file, even though it was passed to the RuntimeException as the cause.
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.XMLFormatter;
public class XMLFormatterDemo {
public static void main(String[] args) {
Logger l = Logger.getAnonymousLogger();
l.setLevel(Level.ALL);
Handler handler;
try {
handler = new FileHandler("log-output.xml");
} catch (IOException e) {
e.printStackTrace();
return;
}
handler.setFormatter(new XMLFormatter());
l.addHandler(handler);
// log an exception
IllegalArgumentException cause = new
IllegalArgumentException("bad argument");
l.log(Level.SEVERE, "Exception", new RuntimeException("Some
error", cause));
}
}
---------- END SOURCE ----------
###@###.### 2005-05-06 05:27:59 GMT