On Tue, 2002-07-23 at 15:03, Bob Herrmann wrote: > On Mon, 2002-07-22 at 14:18, [EMAIL PROTECTED] wrote: > > > > I think there is a simpler solution for this class of problems, and > > that would also work with log4j and doesn't require _any_ API change. > > ( only changes to the adapter implementations ) > > > > Any 'wrapper' will use: > > factory=LogFactory.getFactory(); > > > > factory.setAttribute( "commons-logging.wrapperClass", > > "[CLASSNAME-OF-WRAPPER]"); > > factory.getLog(), etc. >
Hi. This patch to commons logging allow you to specify which methods in the call stack are uninteresting when using the JDK1.4 Logger. In Tomcat this seems to be all methods named "log" and "internalLog." This is based on Costin's idea of uninteresting classes, but seems to work better for method names (in Tomcat anyway.) It is something of a back door. It is primarily for projects that are in the process of converting to using commons-logging. Is this an acceptable change to commons-logging ? Cheers, -bob P.S. this patch is updated from the one posted to tomcat-dev
Index: src/java/org/apache/commons/logging/impl/Jdk14Logger.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/logging/src/java/org/apache/commons/logging/impl/Jdk14Logger.java,v retrieving revision 1.4 diff -u -r1.4 Jdk14Logger.java --- src/java/org/apache/commons/logging/impl/Jdk14Logger.java 17 Jul 2002 16:42:40 -0000 1.4 +++ src/java/org/apache/commons/logging/impl/Jdk14Logger.java 23 Jul 2002 20:49:11 -0000 @@ -65,8 +65,11 @@ import java.util.logging.Level; import java.util.logging.Logger; +import java.util.Hashtable; +import java.util.StringTokenizer; import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** @@ -95,6 +98,14 @@ logger = Logger.getLogger(name); + String wrapperMethods = (String) LogFactory.getFactory().getAttribute("commons-logging.wrapperMethods"); + if ( wrapperMethods != null ){ + StringTokenizer st = new StringTokenizer(wrapperMethods,","); + while (st.hasMoreTokens()) { + wrapperMethodsHash.put( st.nextToken(), "F" ); + } + } + } @@ -106,6 +117,11 @@ */ protected Logger logger = null; + /** + * The methods that we ignore in the stack trace + */ + private Hashtable wrapperMethodsHash = new Hashtable(); + // --------------------------------------------------------- Public Methods @@ -116,10 +132,17 @@ // Caller will be the third element String cname="unknown"; String method="unknown"; - if( locations!=null && locations.length >2 ) { - StackTraceElement caller=locations[2]; - cname=caller.getClassName(); - method=caller.getMethodName(); + if( locations!=null && locations.length>2 ) { + StackTraceElement caller=null; + for (int stackLevel=2;stackLevel<locations.length;stackLevel++){ + caller = locations[stackLevel]; + cname = caller.getClassName(); + method = caller.getMethodName(); + if ( wrapperMethodsHash.get( method ) == null ){ + break; + } + + } } if( ex==null ) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>