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