Commit | Line | Data |
---|---|---|
504d4ace DG |
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 | ||
1258a6f7 | 22 | import org.apache.log4j.Logger; |
e4b5b4e5 | 23 | import org.apache.log4j.BasicConfigurator; |
70cfe01d | 24 | import org.apache.log4j.Level; |
e4b5b4e5 | 25 | import org.lttng.ust.agent.LTTngAgent; |
504d4ace | 26 | |
e4b5b4e5 JG |
27 | public class JTestLTTng |
28 | { | |
29 | private static LTTngAgent lttngAgent; | |
504d4ace | 30 | |
e4b5b4e5 JG |
31 | public static void main(String args[]) throws Exception |
32 | { | |
504d4ace DG |
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 | ||
70cfe01d JR |
40 | /* |
41 | * Set lowest level to make sure all event levels are logged. | |
42 | * Any jar can override the default log4j rootLogger level | |
43 | * and a logger with no explicit level defaults to the non-null | |
44 | * parent level. Events could be ignored if the inherited value | |
45 | * is too low, thereby failing the test. | |
46 | * | |
47 | * See BSF -> https://issues.apache.org/jira/browse/BSF-24 | |
48 | */ | |
49 | lttng.setLevel(Level.ALL); | |
50 | lttng2.setLevel(Level.ALL); | |
51 | ||
504d4ace DG |
52 | if (args.length > 2) { |
53 | fire_debug_tp = Integer.parseInt(args[2]); | |
54 | } | |
55 | if (args.length > 3) { | |
56 | fire_second_tp = Integer.parseInt(args[3]); | |
57 | } | |
58 | ||
59 | BasicConfigurator.configure(); | |
e4b5b4e5 | 60 | lttngAgent = LTTngAgent.getLTTngAgent(); |
504d4ace DG |
61 | |
62 | for (int iter = 0; iter < nrIter; iter++) { | |
63 | lttng.info("LOG4J tp fired!"); | |
64 | if (fire_debug_tp == 1) { | |
65 | /* Third arg, trigger debug TP. */ | |
66 | lttng.debug("LOG4J DEBUG tp fired"); | |
67 | } | |
68 | Thread.sleep(waitTime); | |
69 | } | |
70 | ||
71 | if (fire_second_tp == 1) { | |
72 | lttng2.info("LOG4J second logger fired"); | |
73 | } | |
74 | } | |
75 | } |