java-application: split
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 4 Sep 2015 16:56:40 +0000 (12:56 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 4 Sep 2015 17:20:28 +0000 (13:20 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
contents/using-lttng/instrumenting/java-application.md [deleted file]
contents/using-lttng/instrumenting/java-application/intro.md [new file with mode: 0644]
contents/using-lttng/instrumenting/java-application/jul.md [new file with mode: 0644]
contents/using-lttng/instrumenting/java-application/log4j.md [new file with mode: 0644]
toc/docs.yml

diff --git a/contents/using-lttng/instrumenting/java-application.md b/contents/using-lttng/instrumenting/java-application.md
deleted file mode 100644 (file)
index af51664..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
----
-id: java-application
----
-
-LTTng-UST provides a _logging_ back-end for Java applications using
-either
-<a href="http://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html" class="ext"><code>java.util.logging</code></a>
-(JUL), or
-<a href="http://logging.apache.org/log4j/1.2/" class="ext">Apache log4j 1.2</a>.
-This back-end is called the _LTTng-UST Java agent_, and is responsible
-for communications with an LTTng session daemon.
-
-<div class="tip">
-<p>
-    <span class="t">Note:</span>The latest stable version of LTTng
-    does not support Log4j 2.
-</p>
-</div>
-
-From the user's point of view, once the LTTng-UST Java agent has been
-initialized, JUL and log4j loggers may be created and used as usual.
-The agent adds its own handler to the _root logger_, so that all
-loggers may generate LTTng events with no effort.
-
-Common JUL/log4j features are supported using the `lttng` tool
-(see [Controlling tracing](#doc-controlling-tracing)):
-
-  * listing all logger names
-  * enabling/disabling events per logger name
-  * JUL/log4j log levels
-
-Here's an example using **`java.util.logging`**:
-
-~~~ java
-import java.util.logging.Logger;
-import org.lttng.ust.agent.LTTngAgent;
-
-public class Test
-{
-    private static final int answer = 42;
-
-    public static void main(String[] argv) throws Exception
-    {
-        // create a logger
-        Logger logger = Logger.getLogger("jello");
-
-        // call this as soon as possible (before logging)
-        LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
-
-        // log at will!
-        logger.info("some info");
-        logger.warning("some warning");
-        Thread.sleep(500);
-        logger.finer("finer information; the answer is " + answer);
-        Thread.sleep(123);
-        logger.severe("error!");
-
-        // not mandatory, but cleaner
-        lttngAgent.dispose();
-    }
-}
-~~~
-
-Here's the same example, this time using **log4j**:
-
-~~~ java
-import org.apache.log4j.Logger;
-import org.apache.log4j.BasicConfigurator;
-import org.lttng.ust.agent.LTTngAgent;
-
-public class Test
-{
-    private static final int answer = 42;
-
-    public static void main(String[] argv) throws Exception
-    {
-        // create and configure a logger
-        Logger logger = Logger.getLogger(Test.class);
-        BasicConfigurator.configure();
-
-        // call this as soon as possible (before logging)
-        LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
-
-        // log at will!
-        logger.info("some info");
-        logger.warn("some warning");
-        Thread.sleep(500);
-        logger.debug("debug information; the answer is " + answer);
-        Thread.sleep(123);
-        logger.error("error!");
-        logger.fatal("fatal error!");
-
-        // not mandatory, but cleaner
-        lttngAgent.dispose();
-    }
-}
-~~~
-
-The LTTng-UST Java agent classes are packaged in a JAR file named
-`liblttng-ust-agent.jar`. It is typically located in
-`/usr/lib/lttng/java`. To compile the snippets above
-(saved as `Test.java`), do:
-
-<pre class="term">
-javac -cp /usr/lib/lttng/java/liblttng-ust-agent.jar:$LOG4JCP Test.java
-</pre>
-
-where `$LOG4JCP` is the log4j 1.2 JAR file path, if you're using log4j.
-
-You can run the resulting compiled class like this:
-
-<pre class="term">
-java -cp /usr/lib/lttng/java/liblttng-ust-agent.jar:$LOG4JCP:. Test
-</pre>
-
-<div class="tip">
-<p>
-    <span class="t">Note:</span><a href="http://openjdk.java.net/" class="ext">OpenJDK</a> 7
-    is used for development and continuous integration, thus this
-    version is directly supported. However, the LTTng-UST Java agent has
-    also been tested with OpenJDK 6.
-</p>
-</div>
diff --git a/contents/using-lttng/instrumenting/java-application/intro.md b/contents/using-lttng/instrumenting/java-application/intro.md
new file mode 100644 (file)
index 0000000..31e49d2
--- /dev/null
@@ -0,0 +1,23 @@
+---
+id: java-application
+---
+
+LTTng-UST provides a _logging_ back-end for Java applications using
+either
+<a href="http://docs.oracle.com/javase/7/docs/api/java/util/logging/Logger.html" class="ext"><code>java.util.logging</code></a>
+(JUL) or
+<a href="http://logging.apache.org/log4j/1.2/" class="ext">Apache log4j 1.2</a>.
+This back-end is called the _LTTng-UST Java agent_, and it is responsible
+for the communications with an LTTng session daemon.
+
+From the user's point of view, once the LTTng-UST Java agent has been
+initialized, JUL and log4j loggers may be created and used as usual.
+The agent adds its own handler to the _root logger_, so that all
+loggers may generate LTTng events with no effort.
+
+Common JUL/log4j features are supported using the `lttng` tool
+(see [Controlling tracing](#doc-controlling-tracing)):
+
+  * listing all logger names
+  * enabling/disabling events per logger name
+  * JUL/log4j log levels
diff --git a/contents/using-lttng/instrumenting/java-application/jul.md b/contents/using-lttng/instrumenting/java-application/jul.md
new file mode 100644 (file)
index 0000000..504d737
--- /dev/null
@@ -0,0 +1,60 @@
+---
+id: jul
+---
+
+Here's an example of tracing a Java application which is using
+**`java.util.logging`**:
+
+~~~ java
+import java.util.logging.Logger;
+import org.lttng.ust.agent.LTTngAgent;
+
+public class Test
+{
+    private static final int answer = 42;
+
+    public static void main(String[] argv) throws Exception
+    {
+        // create a logger
+        Logger logger = Logger.getLogger("jello");
+
+        // call this as soon as possible (before logging)
+        LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
+
+        // log at will!
+        logger.info("some info");
+        logger.warning("some warning");
+        Thread.sleep(500);
+        logger.finer("finer information; the answer is " + answer);
+        Thread.sleep(123);
+        logger.severe("error!");
+
+        // not mandatory, but cleaner
+        lttngAgent.dispose();
+    }
+}
+~~~
+
+The LTTng-UST Java agent is packaged in a JAR file named
+`liblttng-ust-agent.jar` It is typically located in
+`/usr/lib/lttng/java`. To compile the snippet above
+(saved as `Test.java`), do:
+
+<pre class="term">
+javac -cp /usr/lib/lttng/java/liblttng-ust-agent.jar Test.java
+</pre>
+
+You can run the resulting compiled class like this:
+
+<pre class="term">
+java -cp /usr/lib/lttng/java/liblttng-ust-agent.jar:. Test
+</pre>
+
+<div class="tip">
+<p>
+    <span class="t">Note:</span><a href="http://openjdk.java.net/" class="ext">OpenJDK</a> 7
+    is used for development and continuous integration, thus this
+    version is directly supported. However, the LTTng-UST Java agent has
+    also been tested with OpenJDK 6.
+</p>
+</div>
diff --git a/contents/using-lttng/instrumenting/java-application/log4j.md b/contents/using-lttng/instrumenting/java-application/log4j.md
new file mode 100644 (file)
index 0000000..916fc08
--- /dev/null
@@ -0,0 +1,64 @@
+---
+id: log4j
+since: 2.6
+---
+
+LTTng features an Apache log4j 1.2 agent, which means your existing
+Java applications using log4j 1.2 for logging can record events to
+LTTng traces with just a minor source code modification.
+
+<div class="tip">
+<p>
+    <span class="t">Note:</span>This version of LTTng does not
+    support Log4j 2.
+</p>
+</div>
+
+Here's an example:
+
+~~~ java
+import org.apache.log4j.Logger;
+import org.apache.log4j.BasicConfigurator;
+import org.lttng.ust.agent.LTTngAgent;
+
+public class Test
+{
+    private static final int answer = 42;
+
+    public static void main(String[] argv) throws Exception
+    {
+        // create and configure a logger
+        Logger logger = Logger.getLogger(Test.class);
+        BasicConfigurator.configure();
+
+        // call this as soon as possible (before logging)
+        LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
+
+        // log at will!
+        logger.info("some info");
+        logger.warn("some warning");
+        Thread.sleep(500);
+        logger.debug("debug information; the answer is " + answer);
+        Thread.sleep(123);
+        logger.error("error!");
+        logger.fatal("fatal error!");
+
+        // not mandatory, but cleaner
+        lttngAgent.dispose();
+    }
+}
+~~~
+
+To compile the snippet above, do:
+
+<pre class="term">
+javac -cp /usr/lib/lttng/java/liblttng-ust-agent.jar:$LOG4JCP Test.java
+</pre>
+
+where `$LOG4JCP` is the log4j 1.2 JAR file path.
+
+You can run the resulting compiled class like this:
+
+<pre class="term">
+java -cp /usr/lib/lttng/java/liblttng-ust-agent.jar:$LOG4JCP:. Test
+</pre>
index c0703c30e4026204be0b203fbc824e61f545658e..c8bfa6d10cb933d180a986dc6d5ac645f7c68245 100644 (file)
@@ -139,6 +139,11 @@ cats:
                 title: Dynamic linker tracing
           - id: java-application
             title: Java application
+            cats:
+              - id: jul
+                title: <code>java.util.logging</code>
+              - id: log4j
+                title: Apache log4j 1.2
           - id: instrumenting-linux-kernel
             title: Linux kernel
             cats:
This page took 0.026456 seconds and 4 git commands to generate.