6 Here's an example of tracing a Java application which is using
7 **`java.util.logging`**:
10 import java.util.logging.Logger;
11 import org.lttng.ust.agent.LTTngAgent;
15 private static final int answer = 42;
17 public static void main(String[] argv) throws Exception
20 Logger logger = Logger.getLogger("jello");
22 // call this as soon as possible (before logging)
23 LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
26 logger.info("some info");
27 logger.warning("some warning");
29 logger.finer("finer information; the answer is " + answer);
31 logger.severe("error!");
33 // not mandatory, but cleaner
39 The LTTng-UST Java agent is packaged in a JAR file named
40 `liblttng-ust-agent.jar` It is typically located in
41 `/usr/lib/lttng/java`. To compile the snippet above
42 (saved as `Test.java`), do:
45 javac -cp /usr/lib/lttng/java/liblttng-ust-agent.jar Test.java
48 You can run the resulting compiled class like this:
51 java -cp /usr/lib/lttng/java/liblttng-ust-agent.jar:. Test
56 <span class="t">Note:</span><a href="http://openjdk.java.net/" class="ext">OpenJDK</a> 7
57 is used for development and continuous integration, thus this
58 version is directly supported. However, the LTTng-UST Java agent has
59 also been tested with OpenJDK 6.