Judging by the tremendous number of replies I see that this is a topic of enormous interest. However, if anyone is interested I was able to effect a work around by adding another filter. Here it is in case anyone is interested. It should be placed in the chain before the TCLFilter:
package your.package; | | | | import java.security.CodeSource; | import java.security.ProtectionDomain; | | import org.apache.log4j.spi.Filter; | import org.apache.log4j.spi.LoggingEvent; | | /** | * Class CSFilter<br> | * An appender filter that evaluates log events to see if the class | * that is specified by the loggerName has a code source that contains | * the string specified in deployURL.<br><br> | * | * It is important that the logger be initialized with a class:<br> | * Logger logger = Logger.getInstance(MyClass.class);<br><br> | * | * This way the loggerName will be a fully qualified class name. This filter | * uses the thread context classloader to load the class and then obtains the | * CodeSource via the ProtectionDomain. It checks the path of the code source | * to see if the url specified in deployURL is contained in it. Therefore it is | * case sensitive. This class should be used in conjunction with the TCLFilter and should | * preced it in the chain because if a match is not found this filter returns NEUTRAL.<br><br> | * | * The acceptOnMatch parameter is only applied when a match is found. If it is true then a match | * returns ACCEPT otherwise when it is false a match returns DENY. | */ | | public class CSFilter extends Filter | { | | /** The deployment URL string fragment to match against */ | | private String deployURL; | | /** Whether a match should return ACCEPT or DENY */ | | private boolean acceptOnMatch = true; | | /** | * Method: decide | * | * | * @param event | * | * @return | */ | | @Override public int decide (LoggingEvent event) | { | int result = Filter.NEUTRAL; | | if (isMatchingCS (event)) | result = acceptOnMatch ? Filter.ACCEPT : Filter.DENY; | | return result; | } | | /** | * Method: getDeployURL | * | * | * @return | */ | | public String getDeployURL () | { | return deployURL; | } | | /** | * Method: isAcceptOnMatch | * | * | * @return | */ | | public boolean isAcceptOnMatch () | { | return acceptOnMatch; | } | | /** | * Method: isMatchingCS | * | * | * @param event | * | * @return | */ | | private boolean isMatchingCS (LoggingEvent event) | { | boolean match = false; | try | { | ClassLoader cl = Thread.currentThread ().getContextClassLoader (); | Class clazz = cl.loadClass (event.getLoggerName ()); | | ProtectionDomain pd = clazz.getProtectionDomain (); | CodeSource clazzCS = pd.getCodeSource (); | | if (clazzCS != null) | { | String path = clazzCS.getLocation ().getPath (); | match = path.contains (deployURL); | } | } | catch (Exception e) | { | // Not much to do in this event | } | | return match; | } | | /** | * Method: setAcceptOnMatch | * | * | * @param acceptOnMatch | */ | | public void setAcceptOnMatch (boolean acceptOnMatch) | { | this.acceptOnMatch = acceptOnMatch; | } | | /** | * Method: setDeployURL | * | * | * @param deployURL | */ | | public void setDeployURL (String deployURL) | { | this.deployURL = deployURL; | } | } | Example from log4j.xml <filter class="your.package.CSFilter"> | <param name="AcceptOnMatch" value="true"/> | <param name="DeployURL" value="YourService.sar"/> | </filter> | <filter class="org.jboss.logging.filter.TCLFilter"> | <param name="AcceptOnMatch" value="true"/> | <param name="DeployURL" value="YourService.sar"/> | </filter> View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4038543#4038543 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4038543 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user