Author: skitching
Date: Sun Apr 16 05:11:05 2006
New Revision: 394466

URL: http://svn.apache.org/viewcvs?rev=394466&view=rev
Log:
Improve diagnostic output

Modified:
    
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java

Modified: 
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
URL: 
http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java?rev=394466&r1=394465&r2=394466&view=diff
==============================================================================
--- 
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
 (original)
+++ 
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
 Sun Apr 16 05:11:05 2006
@@ -455,6 +455,12 @@
                 }
                 
                 factory = newFactory(factoryClass, baseClassLoader, 
contextClassLoader);
+            } else {
+                if (isDiagnosticsEnabled()) {
+                    logDiagnostic(
+                            "[LOOKUP] No system property [" + FACTORY_PROPERTY 
+                            + "] defined.");
+                }
             }
         } catch (SecurityException e) {
             if (isDiagnosticsEnabled()) {
@@ -522,6 +528,13 @@
                         }
                         factory = newFactory(factoryClassName, 
baseClassLoader, contextClassLoader );
                     }
+                } else {
+                    // is == null
+                    if (isDiagnosticsEnabled()) {
+                        logDiagnostic(
+                            "[LOOKUP] No resource file with name '" + 
SERVICE_ID
+                            + "' found.");
+                    }
                 }
             } catch( Exception ex ) {
                 // note: if the specified LogFactory class wasn't compatible 
with LogFactory
@@ -539,32 +552,37 @@
         }
 
 
-        // Third try a properties file.
-        // If the properties file exists, it'll be read and the properties
-        // used. IMHO ( costin ) System property and JDK1.3 jar service
-        // should be enough for detecting the class name. The properties
-        // should be used to set the attributes ( which may be specific to
-        // the webapp, even if a default logger is set at JVM level by a
-        // system property )
+        // Third try looking into the properties file read earlier (if found)
 
         if (factory == null) {
-            if (isDiagnosticsEnabled()) {
-                logDiagnostic(
-                        "[LOOKUP] Looking for a properties file of name '" + 
FACTORY_PROPERTIES
-                        + "' to define the LogFactory subclass to use...");
-            }
             if (props != null) {
                 if (isDiagnosticsEnabled()) {
                     logDiagnostic(
-                        "[LOOKUP] Properties file found. Looking for property 
'" 
+                        "[LOOKUP] Looking in properties file for entry with 
key '" 
                         + FACTORY_PROPERTY
                         + "' to define the LogFactory subclass to use...");
                 }
                 String factoryClass = props.getProperty(FACTORY_PROPERTY);
                 if (factoryClass != null) {
+                    if (isDiagnosticsEnabled()) {
+                        logDiagnostic(
+                            "[LOOKUP] Properties file specifies LogFactory 
subclass '" 
+                            + factoryClass + "'");
+                    }
                     factory = newFactory(factoryClass, baseClassLoader, 
contextClassLoader);
                     
                     // what about handling an exception from newFactory??
+                } else {
+                    if (isDiagnosticsEnabled()) {
+                        logDiagnostic(
+                            "[LOOKUP] Properties file has no entry specifying 
LogFactory subclass.");
+                    }
+                }
+            } else {
+                if (isDiagnosticsEnabled()) {
+                    logDiagnostic(
+                        "[LOOKUP] No properties file available to determine"
+                        + " LogFactory subclass from..");
                 }
             }
         }
@@ -1436,9 +1454,22 @@
             }
         } catch (SecurityException e) {
             if (isDiagnosticsEnabled()) {
-                logDiagnostic("SecurityException thrown");
+                logDiagnostic("SecurityException thrown while trying to 
find/read config files.");
+            }
+        }
+
+        if (isDiagnosticsEnabled()) {
+            if (props == null) {
+                logDiagnostic(
+                    "[LOOKUP] No properties file of name '" + 
FACTORY_PROPERTIES
+                    + "' found.");
+            } else {
+                logDiagnostic(
+                    "[LOOKUP] Properties file of name '" + FACTORY_PROPERTIES
+                    + "' found at '" + propsUrl + '"');
             }
         }
+
         return props;
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to