Test: jul/log4j: use -a instead of '*' to disable all events
[lttng-tools.git] / tests / regression / ust / java-jul / JTestLTTng.java
CommitLineData
37175ce4 1/*
0b7af945 2 * Copyright (C) 2015 - Michael Jeanson <mjeanson@efficios.com>
37175ce4
DG
3 * Copyright (C) 2013 - David Goulet <dgoulet@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
0b7af945 19import java.io.IOException;
37175ce4 20import java.lang.Integer;
0b7af945 21import java.util.logging.Handler;
37175ce4 22import java.util.logging.Logger;
88f54ca9 23import java.util.logging.Level;
37175ce4 24
0b7af945 25import org.lttng.ust.agent.jul.LttngLogHandler;
37175ce4 26
0b7af945
MJ
27public class JTestLTTng {
28
29 /**
30 * Application start
31 *
32 * @param args
33 * Command-line arguments
34 * @throws IOException
35 * @throws InterruptedException
36 */
37 public static void main(String args[]) throws IOException, InterruptedException {
37175ce4 38
37175ce4 39 Logger lttng = Logger.getLogger("JTestLTTng");
9b21e6d5 40 Logger lttng2 = Logger.getLogger("JTestLTTng2");
0b7af945 41
37175ce4
DG
42 int nrIter = Integer.parseInt(args[0]);
43 int waitTime = Integer.parseInt(args[1]);
9b21e6d5
DG
44 int fire_finest_tp = 0;
45 int fire_second_tp = 0;
46
47 if (args.length > 2) {
48 fire_finest_tp = Integer.parseInt(args[2]);
49 }
50 if (args.length > 3) {
51 fire_second_tp = Integer.parseInt(args[3]);
52 }
37175ce4 53
0b7af945
MJ
54 /* Instantiate a LTTngLogHandler object, and attach it to our loggers */
55 Handler lttngHandler = new LttngLogHandler();
56 lttng.addHandler(lttngHandler);
57 lttng2.addHandler(lttngHandler);
58
88f54ca9 59 lttng.setLevel(Level.FINEST);
37175ce4
DG
60
61 for (int iter = 0; iter < nrIter; iter++) {
62 lttng.info("JUL tp fired!");
9b21e6d5 63 if (fire_finest_tp == 1) {
88f54ca9
DG
64 /* Third arg, trigger finest TP. */
65 lttng.finest("JUL FINEST tp fired");
66 }
37175ce4
DG
67 Thread.sleep(waitTime);
68 }
69
9b21e6d5
DG
70 if (fire_second_tp == 1) {
71 lttng2.info("JUL second logger fired");
72 }
73
0b7af945
MJ
74 /*
75 * Do not forget to close() all handlers so that the agent can shutdown
76 * and the session daemon socket gets cleaned up explicitly.
77 */
78 lttngHandler.close();
37175ce4
DG
79 }
80}
This page took 0.028738 seconds and 4 git commands to generate.