DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15585>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15585 log4j does not show Class Name, Method, or Line Number on AS400 [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[EMAIL PROTECTED] Priority|Other |High ------- Additional Comments From [EMAIL PROTECTED] 2003-07-01 12:27 ------- Here are changes I suggest that corrects the problem for log4j class names and line number on AS400. These changes impacts only org.apache.log4j.spi.LocationInfo.java. Note also that Java program on AS400 need to be optimized. Optmisation is defined at level 10, *INTERPRET, 20, 30 or 40. If optimisation is set to 10 or 20 -lowest level-, any exception stack trace are complete, and Class name and line number can be displayed properly. According to tests I have performed, if optimization is at a higher level, stack trace are not complete -lines are missing- so class names and line number may be less precise -corresponding to a "higher" level in the stack trace-, or may be missing totally. Thanks to include these changes in future release. Patrice Changes in org.apache.log4j.spi.LocationInfo.java All new or changed line are starting with a * ----- changes in static definitions -------- // Check if we are running in IBM's visual age. static boolean inVisualAge = false; * // Check if working on as400 * static boolean onAS400 = false; static { try { Class dummy = Class.forName("com.ibm.uvm.tools.DebugSupport"); inVisualAge = true; LogLog.debug("Detected IBM VisualAge environment."); } catch(Throwable e) { // nothing to do } * try { * Properties p = System.getProperties(); * String osname = p.getProperty("os.name"); * if ((osname != null) && (osname.equals("OS/400"))) { * onAS400 = true; * } * LogLog.debug("Detected OS/400 environment."); * } catch(Throwable e) { * // nothing to do * } } ----- Changes in constructor ----------- public LocationInfo(Throwable t, String fqnOfCallingClass) { if(t == null) return; * // on AS400, package path separator in stack trace is not dot '.', * // but slash '/' * if (onAS400) * fqnOfCallingClass = fqnOfCallingClass.replace('.', '/'); String s; // Protect against multiple access to sw. synchronized(sw) { t.printStackTrace(pw); s = sw.toString(); sw.getBuffer().setLength(0); } //System.out.println("s is ["+s+"]."); int ibegin, iend; // Given the current structure of the package, the line // containing "org.apache.log4j.Category." should be printed just // before the caller. // This method of searching may not be fastest but it's safer // than counting the stack depth which is not guaranteed to be // constant across JVM implementations. ibegin = s.lastIndexOf(fqnOfCallingClass); if(ibegin == -1) return; ibegin = s.indexOf(Layout.LINE_SEP, ibegin); if(ibegin == -1) return; ibegin+= Layout.LINE_SEP_LEN; // determine end of line iend = s.indexOf(Layout.LINE_SEP, ibegin); if(iend == -1) return; // VA has a different stack trace format which doesn't // need to skip the inital 'at'. * // -> Same changes for AS400 * if ((!inVisualAge) && (!onAS400)) { // back up to first blank character ibegin = s.lastIndexOf("at ", iend); if(ibegin == -1) return; // Add 3 to skip "at "; ibegin += 3; } // everything between is the requested stack item this.fullInfo = s.substring(ibegin, iend); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
