@ FFDCIgnore ( { MissingResourceException . class , IllegalArgumentException . class } ) protected static Logger createLogger ( final Class < ? > cls , String name , String loggerName ) { ClassLoader orig = getContextClassLoader ( ) ; ClassLoader n = getClassLoader ( cls ) ; if ( n != null ) { setContextClassLoader ( n ) ; } String bundleName = name ; try { Logger logger = null ; ResourceBundle b = null ; if ( bundleName == null ) { //grab the bundle prior to the call to Logger.getLogger(...) so the //ResourceBundle can be loaded outside the big sync block that getLogger really is bundleName = BundleUtils . getBundleName ( cls ) ; try { b = BundleUtils . getBundle ( cls ) ; } catch ( MissingResourceException rex ) { //ignore } } else { bundleName = BundleUtils . getBundleName ( cls , bundleName ) ; try { b = BundleUtils . getBundle ( cls , bundleName ) ; } catch ( MissingResourceException rex ) { //ignore } } if ( b != null ) { b . getLocale ( ) ; } if ( loggerClass != null ) { try { Constructor < ? > cns = loggerClass . getConstructor ( String . class , String . class ) ; if ( name == null ) { try { return ( Logger ) cns . newInstance ( loggerName , bundleName ) ; } catch ( InvocationTargetException ite ) { if ( ite . getTargetException ( ) instanceof MissingResourceException ) { return ( Logger ) cns . newInstance ( loggerName , null ) ; } else { throw ite ; } } } else { try { return ( Logger ) cns . newInstance ( loggerName , bundleName ) ; } catch ( InvocationTargetException ite ) { if ( ite . getTargetException ( ) instanceof MissingResourceException ) { throw ( MissingResourceException ) ite . getTargetException ( ) ; } else { throw ite ; } } } } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } try { logger = Logger . getLogger ( loggerName , bundleName ) ; //NOPMD } catch ( IllegalArgumentException iae ) { //likely a mismatch on the bundle name, just return the default logger = Logger . getLogger ( loggerName ) ; //NOPMD } catch ( MissingResourceException rex ) { logger = Logger . getLogger ( loggerName ) ; //NOPMD } finally { b = null ; } return logger ; } finally { if ( n != orig ) { setContextClassLoader ( orig ) ; } } }
Create a logger