Repository: logging-log4j2
Updated Branches:
  refs/heads/master f063d914b -> 3f5cab4f9


Documentation. User manual subsection for the application main arguments
lookup.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/3f5cab4f
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/3f5cab4f
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/3f5cab4f

Branch: refs/heads/master
Commit: 3f5cab4f989597cafbf0f7d8145622d83233aace
Parents: f063d91
Author: Gary Gregory <[email protected]>
Authored: Sat Sep 27 10:00:12 2014 -0400
Committer: Gary Gregory <[email protected]>
Committed: Sat Sep 27 10:00:12 2014 -0400

----------------------------------------------------------------------
 src/site/xdoc/manual/lookups.xml | 78 +++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/3f5cab4f/src/site/xdoc/manual/lookups.xml
----------------------------------------------------------------------
diff --git a/src/site/xdoc/manual/lookups.xml b/src/site/xdoc/manual/lookups.xml
index 6206206..34274aa 100644
--- a/src/site/xdoc/manual/lookups.xml
+++ b/src/site/xdoc/manual/lookups.xml
@@ -34,6 +34,84 @@
           <a href="./configuration.html#PropertySubstitution">Property 
Substitution</a> section of the
           <a href="./configuration.html">Configuration</a> page.
         </p>
+        <subsection name="Application main arguments lookup">
+          <a name="AppMainArgsLookup"/>
+          <p>
+             You can access the main arguments of an application if they have 
been set with:
+          </p>
+<pre class="prettyprint linenums"><![CDATA[
+import org.apache.logging.log4j.core.lookup.MapLookup;
+
+public static void main(String args[]) {
+  //...
+  MapLookup.setMainArguments(args);
+  //...
+}]]></pre>
+        <p>        
+          Then, if your static void main String[] arguments are:
+        </p>
+        <pre>--file foo.txt --verbose -x bar</pre>
+        <p>
+          I can use the following substitutions with the <code>main</code> 
prefix with a 0-based index or a string:
+        </p>
+        <table>
+          <tr>
+            <th>Expression</th>
+            <th>Result</th>
+          </tr>
+          <tr>
+            <td>${main:0}</td>
+            <td>
+              <p><code>--file</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:1}</td>
+            <td>
+              <p><code>foo.txt</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:2}</td>
+            <td>
+              <p><code>--verbose</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:3}</td>
+            <td>
+              <p><code>-x</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:4}</td>
+            <td>
+              <p><code>bar</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:--file}</td>
+            <td>
+              <p><code>foo.txt</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:-x}</td>
+            <td>
+              <p><code>bar</code></p>
+            </td>
+          </tr>
+          <tr>
+            <td>${main:bar}</td>
+            <td>
+              <p><code>null</code></p>
+            </td>
+          </tr>
+        </table>        
+        <p>
+          Using <code>${main:string}</code> gives you the next value in the 
argument list after the given string.
+        </p>
+        </subsection>  
         <subsection name="ContextMapLookup">
           <a name="ContextMapLookup"/>
           <p>

Reply via email to