Package org.apache.commons.logging

Examples of org.apache.commons.logging.LogConfigurationException


/*     */         }
/*     */         catch (InvocationTargetException e)
/*     */         {
/* 663 */           if (!(e.getTargetException() instanceof SecurityException))
/*     */           {
/* 668 */             throw new LogConfigurationException("Unexpected InvocationTargetException", e.getTargetException());
/*     */           }
/*     */         }
/*     */       }
/*     */       catch (NoSuchMethodException e)
/*     */       {
View Full Code Here


/*      */     }
/*      */     catch (InvocationTargetException e)
/*      */     {
/*  625 */       Throwable c = e.getTargetException();
/*  626 */       if (c != null) {
/*  627 */         throw new LogConfigurationException(c);
/*      */       }
/*  629 */       throw new LogConfigurationException(e);
/*      */     }
/*      */     catch (Throwable t)
/*      */     {
/*      */     }
/*  634 */     throw new LogConfigurationException(t);
/*      */   }
View Full Code Here

/*  793 */           informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.Log4JLogger");
/*  794 */           informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.Jdk14Logger");
/*  795 */           informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.Jdk13LumberjackLogger");
/*  796 */           informUponSimilarName(messageBuffer, specifiedLogClassName, "org.apache.commons.logging.impl.SimpleLog");
/*      */         }
/*  798 */         throw new LogConfigurationException(messageBuffer.toString());
/*      */       }
/*      */
/*  801 */       return result;
/*      */     }
/*      */
/*  832 */     if (isDiagnosticsEnabled()) {
/*  833 */       logDiagnostic("No user-specified Log implementation; performing discovery using the standard supported logging implementations...");
/*      */     }
/*      */
/*  837 */     for (int i = 0; (i < classesToDiscover.length) && (result == null); i++) {
/*  838 */       result = createLogFromClass(classesToDiscover[i], logCategory, true);
/*      */     }
/*      */
/*  841 */     if (result == null) {
/*  842 */       throw new LogConfigurationException("No suitable Log implementation");
/*      */     }
/*      */
/*  846 */     return result;
/*      */   }
View Full Code Here

/*      */         }
/*      */
/* 1188 */         return contextClassLoader;
/*      */       }
/*      */
/* 1191 */       throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via a classloader that is not related to the current context classloader.");
/*      */     }
/*      */
/* 1198 */     if (baseClassLoader != contextClassLoader)
/*      */     {
/* 1204 */       if (this.allowFlawedContext) {
/* 1205 */         if (isDiagnosticsEnabled()) {
/* 1206 */           logDiagnostic("Warning: the context classloader is an ancestor of the classloader that loaded LogFactoryImpl; it should be the same or a descendant. The application using commons-logging should ensure the context classloader is used correctly.");
/*      */         }
/*      */
/*      */       }
/*      */       else
/*      */       {
/* 1214 */         throw new LogConfigurationException("Bad classloader hierarchy; LogFactoryImpl was loaded via a classloader that is not related to the current context classloader.");
/*      */       }
/*      */
/*      */     }
/*      */
/* 1221 */     return baseClassLoader;
View Full Code Here

/* 1283 */     if (isDiagnosticsEnabled()) {
/* 1284 */       LogFactory.logRawDiagnostic("Could not instantiate Log '" + logAdapterClassName + "' -- " + discoveryFlaw.getClass().getName() + ": " + discoveryFlaw.getLocalizedMessage(), discoveryFlaw);
/*      */     }
/*      */
/* 1290 */     if (!this.allowFlawedDiscovery)
/* 1291 */       throw new LogConfigurationException(discoveryFlaw);
/*      */   }
View Full Code Here

/* 1360 */         msg.append(Log.class.getName());
/* 1361 */         msg.append("' visible.");
/* 1362 */         if (isDiagnosticsEnabled()) {
/* 1363 */           logDiagnostic(msg.toString());
/*      */         }
/* 1365 */         throw new LogConfigurationException(msg.toString());
/*      */       }
/*      */
/* 1368 */       if (isDiagnosticsEnabled()) {
/* 1369 */         StringBuffer msg = new StringBuffer();
/* 1370 */         msg.append("Warning: bad log hierarchy. ");
/* 1371 */         msg.append("You have more than one version of '");
/* 1372 */         msg.append(Log.class.getName());
/* 1373 */         msg.append("' visible.");
/* 1374 */         logDiagnostic(msg.toString());
/*      */       }
/*      */     }
/*      */     else {
/* 1378 */       if (!this.allowFlawedDiscovery) {
/* 1379 */         StringBuffer msg = new StringBuffer();
/* 1380 */         msg.append("Terminating logging for this context. ");
/* 1381 */         msg.append("Log class '");
/* 1382 */         msg.append(badClass.getName());
/* 1383 */         msg.append("' does not implement the Log interface.");
/* 1384 */         if (isDiagnosticsEnabled()) {
/* 1385 */           logDiagnostic(msg.toString());
/*      */         }
/*      */
/* 1388 */         throw new LogConfigurationException(msg.toString());
/*      */       }
/*      */
/* 1391 */       if (isDiagnosticsEnabled()) {
/* 1392 */         StringBuffer msg = new StringBuffer();
/* 1393 */         msg.append("[WARNING] Log class '");
View Full Code Here

/*     */         }
/*     */         catch (InvocationTargetException e)
/*     */         {
/* 669 */           if (!(e.getTargetException() instanceof SecurityException))
/*     */           {
/* 674 */             throw new LogConfigurationException("Unexpected InvocationTargetException", e.getTargetException());
/*     */           }
/*     */         }
/*     */       }
/*     */       catch (NoSuchMethodException e)
/*     */       {
View Full Code Here

        } catch (InvocationTargetException e) {
            // A problem occurred invoking the Constructor or Method
            // previously discovered
            Throwable c = e.getTargetException();
            if (c != null) {
                throw new LogConfigurationException(c);
            } else {
                throw new LogConfigurationException(e);
            }
        } catch (Throwable t) {
            // A problem occurred invoking the Constructor or Method
            // previously discovered
            throw new LogConfigurationException(t);
        }
    }
View Full Code Here

                    informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LOG4J_LOGGER);
                    informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_JDK14_LOGGER);
                    informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LUMBERJACK_LOGGER);
                    informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_SIMPLE_LOGGER);
                }
                throw new LogConfigurationException(messageBuffer.toString());
            }
           
            return result;
        }
       
        // No user specified log; try to discover what's on the classpath
        //
        // Note that we deliberately loop here over classesToDiscover and
        // expect method createLogFromClass to loop over the possible source
        // classloaders. The effect is:
        //   for each discoverable log adapter
        //      for each possible classloader
        //          see if it works
        //
        // It appears reasonable at first glance to do the opposite:
        //   for each possible classloader
        //     for each discoverable log adapter
        //        see if it works
        //
        // The latter certainly has advantages for user-installable logging
        // libraries such as log4j; in a webapp for example this code should
        // first check whether the user has provided any of the possible
        // logging libraries before looking in the parent classloader.
        // Unfortunately, however, Jdk14Logger will always work in jvm>=1.4,
        // and SimpleLog will always work in any JVM. So the loop would never
        // ever look for logging libraries in the parent classpath. Yet many
        // users would expect that putting log4j there would cause it to be
        // detected (and this is the historical JCL behaviour). So we go with
        // the first approach. A user that has bundled a specific logging lib
        // in a webapp should use a commons-logging.properties file or a
        // service file in META-INF to force use of that logging lib anyway,
        // rather than relying on discovery.
       
        if (isDiagnosticsEnabled()) {
            logDiagnostic(
                "No user-specified Log implementation; performing discovery" +
              " using the standard supported logging implementations...");
        }
        for(int i=0; (i<classesToDiscover.length) && (result == null); ++i) {
            result = createLogFromClass(classesToDiscover[i], logCategory, true);
        }
       
        if (result == null) {
            throw new LogConfigurationException
                        ("No suitable Log implementation");
        }
       
        return result;       
    }
View Full Code Here

              // have returned thisClassLoader.  The fact we are here means
              // contextClassLoader is not null, so we can just return it.
              return contextClassLoader;
           }
           else {
            throw new LogConfigurationException(
                "Bad classloader hierarchy; LogFactoryImpl was loaded via"
                + " a classloader that is not related to the current context"
                + " classloader.");
           }          
        }

        if (baseClassLoader != contextClassLoader) {
            // We really should just use the contextClassLoader as the starting
            // point for scanning for log adapter classes. However it is expected
            // that there are a number of broken systems out there which create
            // custom classloaders but fail to set the context classloader so
            // we handle those flawed systems anyway.
            if (allowFlawedContext) {
                if (isDiagnosticsEnabled()) {
                    logDiagnostic(
                            "Warning: the context classloader is an ancestor of the"
                            + " classloader that loaded LogFactoryImpl; it should be"
                            + " the same or a descendant. The application using"
                            + " commons-logging should ensure the context classloader"
                            + " is used correctly.");
                }
            } else {
                throw new LogConfigurationException(
                        "Bad classloader hierarchy; LogFactoryImpl was loaded via"
                        + " a classloader that is not related to the current context"
                        + " classloader.");
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.logging.LogConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.