===== log4j-groovy ===== Log4j with some patches to support Groovy file and line numbers in logs. It enables full integration with log4j including class name filtering, stack trace and more details. It is tested with Groovy 1.6, there is also version for Groovy 1.5. It is used with direct log4j calls, I am not sure how it will behave with wrappers like commons-logging. DOWNLOAD: {{projects:groovy16-log4j.zip|Current version for Groovy 1.6}} {{projects:log4j-groovy.zip| Old version for Groovy 1.5}} This file is normal log4j with one addional patch // addd code between GROOVY fix to // org.apache.log4j.spi.LocationInfo:106 public LocationInfo(Throwable t, String fqnOfCallingClass) { if(t == null) return; String s; // Protect against multiple access to sw. synchronized(sw) { t.printStackTrace(pw); s = sw.toString(); sw.getBuffer().setLength(0); } 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; //START OF GROOVY PATCH //test if was called by proxy, may not work on all VM, tested on Sun JRE 1.6 int len = ibegin+800+fqnOfCallingClass.length(); if(len>s.length()) len = s.length(); String subs = s.substring(ibegin,len); if(subs.contains("(Native Method)")|| subs.contains("(Unknown Source)")||subs.contains("sun.reflect")){ final String GROOVY_FGN = "org.codehaus.groovy.runtime.callsite.AbstractCallSite.call"; ibegin = s.lastIndexOf(Layout.LINE_SEP,s.indexOf("groovy:", s.indexOf(GROOVY_FGN))); if(ibegin == -1) return; } //END OF GROOVY PATCH