When problems occur in open source software users tend to get stack traces. They often fire them off to some open source mailing list or forum asking for help; often without providing much in the way of detail. One of the first questions asked by support teams is often 'OK, what version are you using'.
Given that its possible to figure out the actual version being used of each class - either using the package information from the MANIFEST or by finding the jar the class came from, it seems logical to include the version information into a stack trace at the end of the line. One day the JVM might actually do this for us :) In the meantime, here's a trivial patch which appends an optional String to stack traces printed with log4j which includes the jar file name if it can be deduced plus the Java Package version the line of code comes from. https://issues.apache.org/bugzilla/show_bug.cgi?id=45721 Here's an example... org.apache.log4j.config.PropertySetterException: Hello at org.apache.log4j.spi.ThrowableInformationTest.testStackTracePackageName(ThrowableInformationTest.java:306) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [1.5.0] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [1.5.0] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [1.5.0] at java.lang.reflect.Method.invoke(Method.java:585) [1.5.0] at junit.framework.TestCase.runTest(TestCase.java:154) [junit-3.8.1.jar] at junit.framework.TestCase.runBare(TestCase.java:127) [junit-3.8.1.jar] at junit.framework.TestResult$1.protect(TestResult.java:106) [junit-3.8.1.jar] at junit.framework.TestResult.runProtected(TestResult.java:124) [junit-3.8.1.jar] at junit.framework.TestResult.run(TestResult.java:109) [junit-3.8.1.jar] at junit.framework.TestCase.run(TestCase.java:118) [junit-3.8.1.jar] at junit.textui.TestRunner.doRun(TestRunner.java:116) [junit-3.8.1.jar] at com.intellij.rt.execution.junit.IdeaTestRunner.doRun(IdeaTestRunner.java:94) [idea_rt.jar] at junit.textui.TestRunner.doRun(TestRunner.java:109) [junit-3.8.1.jar] at com.intellij.rt.execution.junit.IdeaTestRunner.startRunnerWithArgs(IdeaTestRunner.java:22) [idea_rt.jar] at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:118) [idea_rt.jar] at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) [idea_rt.jar] So you can see what version of junit is being used (despite there being no manifest information) along with the JDK implementation version. e.g. at java.lang.reflect.Method.invoke(Method.java:585) [1.5.0] means we found the package number but couldn't find the jar file. Whereas at junit.framework.TestCase.run(TestCase.java:118) [junit-3.8.1.jar] means we found the jar file but the jar file has no manifest version information. Thoughts? James -- View this message in context: http://www.nabble.com/-PATCH--when-showing-a-stack-trace---include-the-relative-package-versions-and-optional-jar-name-to-aid-debugging-tp19254233p19254233.html Sent from the Log4j - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
