-The LTTng-UST JUL agent Java classes are packaged in a JAR file named
-`liblttng-ust-jul.jar`. It is typically located in
-`/usr/lib/lttng/java`. To compile the snippet above
+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