Version 11

    Enable Classloader Logging

     

    Log4J with a single ucl.log

     

    All JBoss logging is based on Log4j.  Classloader logging is no different.  To enable logging for classloaders, edit log4j.xml in the $JBOSS_HOME/server/xxx/conf/log4j.xml and add

     

        <appender name="UCL" class="org.apache.log4j.FileAppender">
            <param name="File" value="${jboss.server.home.dir}/log/ucl.log"/>
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="[%r,%c{1},%t] %m%n"/>
            </layout>
        </appender>
    
        <category name="org.jboss.mx.loading" additivity="false">
            <priority value="TRACE" class="org.jboss.logging.XLevel"></priority>
            <appender-ref ref="UCL"></appender-ref>
        </category>
    

     

    The additivity="false" attribute says to only send the org.jboss.mx.loading category output to the associated appender-ref. If you want output to go to the server.log in addition to the ucl.log set additivity="true". If you only want the output to go to the server.log, set additivity="true" and remove the appender-ref element. The UCL appender creates a ucl.log in the /server/xxx/log directory which will contain output such as:

     

    [664629,UnifiedClassLoader3,Thread-1] attempt(1) was: true for :org.jboss.mx.loading.UnifiedClassLoader3@186768e{
       url=file:/jboss-3.0.8-management/server/default/tmp/deploy/server/default/conf/jboss-service.xml/1.jboss-service.xml ,addedOrder=2}
    [664629,LoadMgr,Thread-1] registerLoaderThread, ucl=org.jboss.mx.loading.UnifiedClassLoader3@186768e{ 
       url=file:/jboss-3.0.8-management/server/default/tmp/deploy/server/default/conf/jboss-service.xml/1.jboss-service.xml 
       ,addedOrder=2}, t=Thread[Thread-1,5,jboss], prevT=null
    [664630,LoadMgr,Thread-1] Begin beginLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@174a144{classname: org.apache.log4j.PatternLayout,
       requestingThread: Thread[Thread-1,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@186768e{
       url=file:/jboss-3.0.8-management/server/default/tmp/deploy/server/default/conf/jboss-service.xml/1.jboss-service.xml 
       ,addedOrder=2},
       loadedClass: null, loadOrder: 2147483647, loadException: null, threadTaskCount: 0, state: 0}
    [664630,LoadMgr,Thread-1] End beginLoadTask, loadClassFromCache
    [664630,LoadMgr,Thread-1] Begin endLoadTask, task=org.jboss.mx.loading.ClassLoadingTask@174a144{classname: org.apache.log4j.PatternLayout,
       requestingThread: Thread[Thread-1,5,jboss], requestingClassLoader: org.jboss.mx.loading.UnifiedClassLoader3@186768e{ 
       url=file:/jboss-3.0.8-management/server/default/tmp/deploy/server/default/conf/jboss-service.xml/1.jboss-service.xml ,addedOrder=2},
       loadedClass: class org.apache.log4j.PatternLayout@1e51060, loadOrder: 2147483647, loadException: null, threadTaskCount: 0, state: 4}
    [664630,UnifiedClassLoader3,Thread-1] release(1) for :org.jboss.mx.loading.UnifiedClassLoader3@186768e{ 
       url=file:/jboss-3.0.8-management/server/default/tmp/deploy/server/default/conf/jboss-service.xml/1.jboss-service.xml ,addedOrder=2}
    [664630,UnifiedClassLoader3,Thread-1] released, holds: 0
    

     

    Much of the output will be specific to the jboss class loader implementation, but the main class loading loadClass entry point will be shown. Other key messages are the LoadMgr beginLoadTask, nextTask and endLoadTask calls.

     

    Log4J with a rolling ucl.log

    At times you need to trace loading for an extended period of time, and the FileAppender will generate too large of a log file. You can use a RollingFileAppender to generate a fixed number of fixed size logs. For example, this configuration uses a maximum of two ucl.log files of size 5MB:

     

        <appender name="UCL" class="org.apache.log4j.RollingFileAppender">
            <param name="File" value="${jboss.server.home.dir}/log/ucl.log"/>
            <param name="MaxFileSize" value="5MB"/>
            <param name="MaxBackupIndex" value="1"/>
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="[%r,%c{1},%t] %m%n"/>
            </layout>
        </appender>
    
        <category name="org.jboss.mx.loading" additivity="false">
            <priority value="TRACE" class="org.jboss.logging.XLevel"></priority>
            <appender-ref ref="UCL"></appender-ref>
        </category>
    

     

    The MaxBackupIndex controls how many log files will be kept around.