You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ah...@apache.org on 2005/12/30 01:06:50 UTC

svn commit: r359934 - /maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java

Author: aheritier
Date: Thu Dec 29 16:06:46 2005
New Revision: 359934

URL: http://svn.apache.org/viewcvs?rev=359934&view=rev
Log:
PR: MAVEN-1735
Submitted by: -
Reviewed by: aheritier
Allow to setup logging configuration with log4j properties.

Modified:
    maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java

Modified: maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java?rev=359934&r1=359933&r2=359934&view=diff
==============================================================================
--- maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java (original)
+++ maven/maven-1/core/trunk/src/java/org/apache/maven/cli/App.java Thu Dec 29 16:06:46 2005
@@ -25,6 +25,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
 import org.apache.maven.MavenConstants;
 import org.apache.maven.MavenException;
 import org.apache.maven.MavenSession;
@@ -292,8 +293,31 @@
         initializeSystemProperties();
         initializeRootContext();
         initializeMavenSession();
+        customizeLogging();
     }
 
+    /**
+     * Customize the log4j configuration from properties 
+     * (read in system, user or project scope).
+     */
+    private void customizeLogging()
+    {
+        Iterator iter = getRootContext().getVariableNames();
+        Properties log4jProperties = new Properties();
+        String propertyName;
+        while ( iter.hasNext() )
+        {
+            propertyName = (String) iter.next();
+            if ( propertyName.startsWith( "log4j" ) )
+            {
+                log4jProperties.put( propertyName, getRootContext().getVariable( propertyName ) );
+            }
+        }
+        PropertyConfigurator.configure( log4jProperties );
+        log4jProperties = null;
+        iter=null;
+    }
+    
     /**
      * Get the project descriptor file.
      *