You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2012/08/24 06:59:22 UTC

svn commit: r1376825 - /logging/log4j/log4j2/trunk/src/site/xdoc/manual/plugins.xml

Author: rgoers
Date: Fri Aug 24 04:59:22 2012
New Revision: 1376825

URL: http://svn.apache.org/viewvc?rev=1376825&view=rev
Log:
Document invoking the PluginManager during a build.

Modified:
    logging/log4j/log4j2/trunk/src/site/xdoc/manual/plugins.xml

Modified: logging/log4j/log4j2/trunk/src/site/xdoc/manual/plugins.xml
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/src/site/xdoc/manual/plugins.xml?rev=1376825&r1=1376824&r2=1376825&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/src/site/xdoc/manual/plugins.xml (original)
+++ logging/log4j/log4j2/trunk/src/site/xdoc/manual/plugins.xml Fri Aug 24 04:59:22 2012
@@ -100,6 +100,38 @@
             key is the name of the item to locate.
           </p>
         </subsection>
+        <a name="Plugin Preloading"/>
+        <subsection name="Plugin Preloading">
+          Scanning for annotated classes dynamically takes a bit of time during application initialization. Log4j
+          avoids this by scanning its classes during the build. In the Maven build, the PluginManager is invoked as
+          shown below and then the resulting Map is stored in a file in the jar being constructed. Log4j will locate
+          all the files created this way and and preload them, which shortens startup time considerably. Adding the
+          following plugin definition to your project's pom.xml will cause the plugin manager to be called during the
+          build. It will store the resulting file in the correct location under the directory specified in the first
+          argument after scanning all the components located under the package specified in the second argument.
+          <source><![CDATA[
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <version>1.2.1</version>
+        <executions>
+          <execution>
+            <phase>process-classes</phase>
+            <goals>
+              <goal>java</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <mainClass>org.apache.logging.log4j.core.config.plugins.PluginManager</mainClass>
+          <arguments>
+            <argument>${project.build.outputDirectory}</argument>
+            <argument>org.myorg.myproject.log4j</argument>
+          </arguments>
+        </configuration>
+      </plugin>
+  ]]></source>
+        </subsection>
       </section>
     </body>
 </document>