2 * Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
3 * Christian Babeux <christian.babeux@efficios.com>
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.
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
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.
19 import java
.io
.IOException
;
20 import java
.lang
.Integer
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.apache
.log4j
.BasicConfigurator
;
24 import org
.apache
.log4j
.Level
;
25 import org
.lttng
.ust
.agent
.LTTngAgent
;
27 public class JTestLTTng
29 private static LTTngAgent lttngAgent
;
31 public static void main(String args
[]) throws Exception
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;
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.
47 * See BSF -> https://issues.apache.org/jira/browse/BSF-24
49 lttng
.setLevel(Level
.ALL
);
50 lttng2
.setLevel(Level
.ALL
);
52 if (args
.length
> 2) {
53 fire_debug_tp
= Integer
.parseInt(args
[2]);
55 if (args
.length
> 3) {
56 fire_second_tp
= Integer
.parseInt(args
[3]);
59 BasicConfigurator
.configure();
60 lttngAgent
= LTTngAgent
.getLTTngAgent();
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");
68 Thread
.sleep(waitTime
);
71 if (fire_second_tp
== 1) {
72 lttng2
.info("LOG4J second logger fired");
This page took 0.037995 seconds and 4 git commands to generate.