- private static LTTngAgent lttngAgent;
-
- public static void main(String args[]) throws Exception
- {
- /*
- * For this example, a custom "hello" logger is created. Note that JUL
- * has a default "global" that can also be used.
- */
- Logger helloLog = Logger.getLogger("hello");
-
- /*
- * Get the LTTngAgent singelton reference. This will also initialize
- * the Agent and make it register to the session daemon if available.
- * When this returns, the Agent is registered and fully ready. If no
- * session daemon is found, it will return and retry every 3 seconds in
- * the background. TCP is used for communication.
- *
- * Note that the LTTngAgent once registered is a seperate thread in
- * your Java application.
- */
- lttngAgent = LTTngAgent.getLTTngAgent();
-
- /*
- * Gives you time to do some lttng commands before any event is hit.
- */
- Thread.sleep(5000);
-
- /* Trigger a tracing event using the JUL Logger created before. */
- helloLog.info("Hello World, the answer is " + answer);
-
- /*
- * From this point on, the above message will be collected in the trace
- * if the event "hello" is enabled for the JUL domain using the lttng
- * command line or the lttng-ctl API. For instance:
- *
- * $ lttng enable-event -j hello
- *
- * A new logger is created here and fired after. The Agent has an
- * internal timer that is fired every 5 seconds in order to enable
- * events that were not found at first but might need to be enabled
- * when new Logger appears. Unfortunately, there is no way right now to
- * get notify of that so we have to actively poll.
- *
- * Using the --all command for instance, it will make this Logger
- * available in a LTTng trace after the internal Agent's timer is
- * fired. (lttng enable-event -a -j).
- */
- Logger helloLogDelayed = Logger.getLogger("hello_delay");