0019cb825b7d4fff1a4163d5a1fb3e102540df2d
[lttng-tools.git] / tests / regression / ust / java-log4j / JTestLTTng.java
1 /*
2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
3 * Christian Babeux <christian.babeux@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License, version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 51
16 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 import java.io.IOException;
20 import java.lang.Integer;
21
22 import org.apache.log4j.Logger;
23 import org.apache.log4j.BasicConfigurator;
24
25 import org.lttng.ust.agent.LTTngAgent;
26
27 public class JTestLTTng
28 {
29 private static LTTngAgent lttngAgent;
30
31 public static void main(String args[]) throws Exception
32 {
33 Logger lttng = Logger.getLogger("log4j-event");
34 Logger lttng2 = Logger.getLogger("log4j-event-2");
35 int nrIter = Integer.parseInt(args[0]);
36 int waitTime = Integer.parseInt(args[1]);
37 int fire_debug_tp = 0;
38 int fire_second_tp = 0;
39
40 if (args.length > 2) {
41 fire_debug_tp = Integer.parseInt(args[2]);
42 }
43 if (args.length > 3) {
44 fire_second_tp = Integer.parseInt(args[3]);
45 }
46
47 BasicConfigurator.configure();
48 lttngAgent = LTTngAgent.getLTTngAgent();
49
50 for (int iter = 0; iter < nrIter; iter++) {
51 lttng.info("LOG4J tp fired!");
52 if (fire_debug_tp == 1) {
53 /* Third arg, trigger debug TP. */
54 lttng.debug("LOG4J DEBUG tp fired");
55 }
56 Thread.sleep(waitTime);
57 }
58
59 if (fire_second_tp == 1) {
60 lttng2.info("LOG4J second logger fired");
61 }
62 }
63 }
This page took 0.040633 seconds and 3 git commands to generate.