protected void parseCategory ( Element loggerElement ) { // Create a new org.apache.log4j.Category object from the <category> element. String catName = subst ( loggerElement . getAttribute ( NAME_ATTR ) ) ; Logger cat ; String className = subst ( loggerElement . getAttribute ( CLASS_ATTR ) ) ; if ( EMPTY_STR . equals ( className ) ) { LogLog . debug ( "Retreiving an instance of org.apache.log4j.Logger." ) ; cat = ( catFactory == null ) ? repository . getLogger ( catName ) : repository . getLogger ( catName , catFactory ) ; } else { LogLog . debug ( "Desired logger sub-class: [" + className + ' ' ) ; try { Class clazz = Loader . loadClass ( className ) ; Method getInstanceMethod = clazz . getMethod ( "getLogger" , ONE_STRING_PARAM ) ; cat = ( Logger ) getInstanceMethod . invoke ( null , new Object [ ] { catName } ) ; } catch ( Exception oops ) { LogLog . error ( "Could not retrieve category [" + catName + "]. Reported error follows." , oops ) ; return ; } } // Setting up a category needs to be an atomic operation, in order // to protect potential log operations while category // configuration is in progress. synchronized ( cat ) { boolean additivity = OptionConverter . toBoolean ( subst ( loggerElement . getAttribute ( ADDITIVITY_ATTR ) ) , true ) ; LogLog . debug ( "Setting [" + cat . getName ( ) + "] additivity to [" + additivity + "]." ) ; cat . setAdditivity ( additivity ) ; parseChildrenOfLoggerElement ( loggerElement , cat , false ) ; } }
Used internally to parse an category element .