1 2 3 Previous Next 39 Replies Latest reply on Feb 3, 2013 10:23 AM by arnabsarkar Go to original post
      • 15. Re: TCLFilter
        jaikiran

         

        "alesj" wrote:

        Or is this just intended for web?


        It was only intended for web, since that's where this showed up as an issue.

        How does this retrieve urls from BaseClassLoader?
        e.g. in non web wrapped ENCLoader (or something similar)


        Right now that class (and i believe the entire component) has no knowledge of jboss-classloader.

        • 16. Re: TCLFilter
          alesj

          This is how it would look like for any classloader in MC/AS5:

           private boolean isMatchingTCL()
           {
           ClassLoader tcl = Thread.currentThread().getContextClassLoader();
           if( matchSet.contains(tcl) )
           return true;
           if( missSet.contains(tcl) )
           return false;
          
           // Search the class loader URLs for a match
           ClassLoader cl = tcl;
           while( cl != null )
           {
           if (matchClassLoader(cl))
           break;
          
           cl = cl.getParent();
           }
          
           if( cl != null )
           matchSet.add(tcl);
           else
           missSet.add(tcl);
          
           return (cl != null);
           }
          
           private boolean matchClassLoader(ClassLoader cl)
           {
           Module module = ClassLoading.getModuleForClassLoader(cl);
           if (module == null)
           return false;
          
           MatchFragment mf = new MatchFragment();
           module.visit(mf, null, mf);
           return mf.isFound();
           }
          
           private class MatchFragment implements ResourceVisitor, ResourceFilter
           {
           private boolean found;
           private boolean visited;
          
           public ResourceFilter getFilter()
           {
           return null;
           }
          
           public boolean accepts(ResourceContext rc)
           {
           if (visited)
           {
           visited = false; // reset recursion filter
           return false;
           }
           return true;
           }
          
           public void visit(ResourceContext rc)
           {
           visited = true;
          
           if (found)
           return;
          
           String rcString = rc.getUrl().toExternalForm();
           found = rcString.contains(deployURL);
           }
          
           public boolean isFound()
           {
           return found;
           }
           }
          


          We cannot unfortunately escape jboss-classloading dependency,
          but there are no hacks, just pure API usage. :-)


          • 17. Re: TCLFilter
            vickyk

             

            "alesj" wrote:
            This is how it would look like for any classloader in MC/AS5:

            Interesting and to understand it one definitely need more understanding about the Classloading project.
            Let me spend some time to understand the usage of the CL API.


            • 18. Re: TCLFilter
              alesj

               

              "vickyk" wrote:

              Interesting and to understand it one definitely need more understanding about the Classloading project.
              Let me spend some time to understand the usage of the CL API.

              To help you learn it, some shameless PR :-)
              * http://java.dzone.com/articles/jboss-microcontainer-classloading

              • 19. Re: TCLFilter
                vickyk

                 

                "alesj" wrote:

                To help you learn it, some shameless PR :-)
                * http://java.dzone.com/articles/jboss-microcontainer-classloading

                lol !!! for shameless PR
                Thanks, I must say that I have been looking at it from the first day of its posting on dzone.
                I am more in looking at the implementation details, I like the block diagrams at this post !
                There is no better documentation other than the source code ;)


                • 20. Re: TCLFilter
                  johk

                  Ales,

                   

                  I've just taken a look at the source for TCLFilter in jboss-logging-log4j-2.1.1.GA.jar and it doesn't seem to implement the matchClassLoader() method as suggested in your previous post.

                   

                  I'm trying to log output from different EARs to separate files - am I right in thinking this is still broken in jBoss AS 5.1.0 even when jboss-logging is replaced with the 2.1.1 version?

                  • 21. Re: TCLFilter
                    vickyk

                    Yes TCLFilter will not work with JB5, you can try the new implemenation from here

                    https://jira.jboss.org/jira/browse/JBLOGGING-21

                    https://jira.jboss.org/jira/secure/attachment/12330235/TCLFilter.java

                    It is based on the Ales's input!

                    • 22. Re: TCLFilter
                      johk

                      So,

                       

                      There is no official release of jboss-logging with a TclFilter that works for EARs?

                      My only option is to compile my own copy of TclFilter using the source attached to jblogging-21?

                       

                      Which version of jboss-logging does the TclFilter attached to jblogging-21 compile against - it doesn't seem to extend AbstractTCLFilter as the TclFilter in jboss-logging-2.1.1.GA does?

                       

                      Thanks,

                      Keith

                      • 23. Re: TCLFilter
                        jaikiran
                        jboss-logging-log4j 2.1.1 GA should have it. How did you configure the TCLFilter in the jboss-log4j.xml. Can you post that snippet?
                        • 24. Re: TCLFilter
                          johk

                          Attached my logging config.

                           

                          Notes:

                          • Running jboss-5.1.0-jdk6, patched with the jboss-logging-2.1.1.GA jars.
                          • ash.ear is deployed as normal in server/default/deploy.
                          • All output continues to be written to the console.
                          • The ash.log file is created, but contains 0 bytes of data.

                           

                          My understanding was that the fix discussed in https://jira.jboss.org/jira/browse/JBLOGGING-30 only fixes this issue for WAR files, not for EAR files.

                           

                          Fixed markup.

                          • 25. Re: TCLFilter
                            alesj
                            My understanding was that the fix discussed in https://jira.jboss.org/jira/browse/JBLOGGING-30 only fixes this issue for WAR files, not for EAR files.

                            Afaiu, initial version was "hacked" for web/war only, as it was using the fact that there was some URLCL involved.

                            But my proposal should work for any deployment as long as the right TCCL is involved.

                            • 26. Re: TCLFilter
                              jaikiran

                              {quote}

                              {code:xml}<filter class="org.jboss.logging.filter.TCLFilter">
                                      <param name="AcceptOnMatch" value="true"/>
                                      <param name="DeployURL" value="ash.ear"/>
                                    </filter>{code}{quote}

                               

                              You are using the wrong filter class. With this fix, you should be using:

                               

                              {code:xml}<filter class="org.jboss.logging.filter.TCLMCFilter">{code}

                               

                              The wiki [http://community.jboss.org/wiki/SeparatingApplicationLogs] has more details.

                               

                              • 27. Re: TCLFilter
                                johk

                                But my proposal should work for any deployment as long as the right TCCL is involved.

                                 

                                That was I took from your post.

                                 

                                I'm trying to establish whether your proposal was incorporated into jboss-logging-2.1.1?

                                In other words, does jboss-logging-2.1.1 support separate log files for EARs.

                                 

                                If not, what is the best way to get separate logging for EARs working under jBoss-5.1.0?

                                • 28. Re: TCLFilter
                                  johk

                                  jaikiran wrote:

                                   

                                   

                                  <filter class="org.jboss.logging.filter.TCLFilter">        <param name="AcceptOnMatch" value="true"/>        <param name="DeployURL" value="ash.ear"/>      </filter>

                                   

                                   

                                  You are using the wrong filter class. With this fix, you should be using:

                                   

                                  <filter class="org.jboss.logging.filter.TCLMCFilter">

                                   

                                  The wiki SeparatingApplicationLogs has more details.

                                   

                                   

                                   

                                  Fantastic!

                                  It's working now with the correct filter class.

                                   

                                  Might I suggest that you update the wiki page to indicate that the TCLMCFilter works with jBoss 5.1.0? At present the only mention of it is under a section entitled 'JBoss AS 6.0'.

                                   

                                  Also, is there a way to exclude filtered output from other logs, such as the console log. In other words, is it possible to have the console appender only show output not written by another appender?

                                  • 29. Re: TCLFilter
                                    jaikiran

                                    johk wrote:

                                     


                                    Fantastic!

                                    It's working now with the correct filter class.

                                     

                                    Might I suggest that you update the wiki page to indicate that the TCLMCFilter works with jBoss 5.1.0? At present the only mention of it is under a section entitled 'JBoss AS 6.0'.


                                     

                                    The wiki is open for edits for all community users. So if you are interested, then feel free to add how you got this working on 5.1.0 If not, i'll add something later today/tomorrow.

                                     

                                     

                                     

                                    Also, is there a way to exclude filtered output from other logs, such as the console log. In other words, is it possible to have the console appender only show output not written by another appender?

                                    This is a more of log4j configuration thing and is possible. Look for "additivity" attribute on a category/logger in log4j documentation. This has some information http://logging.apache.org/log4j/1.2/manual.html (section Appenders and Layouts)