Commit | Line | Data |
---|---|---|
0fd2fd15 MJ |
1 | /* |
2 | * Copyright (C) 2015 Michael Jeanson <mjeanson@efficios.com> | |
3 | * Copyright (C) 2014 David Goulet <dgoulet@efficios.com> | |
4 | * Copyright (C) 2014 Christian Babeux <christian.babeux@efficios.com> | |
5 | * | |
6 | * SPDX-License-Identifier: GPL-2.0-only | |
7 | * | |
8 | */ | |
9 | ||
10 | import java.io.IOException; | |
11 | import java.lang.Integer; | |
12 | ||
13 | import org.apache.logging.log4j.Logger; | |
14 | import org.apache.logging.log4j.LogManager; | |
15 | ||
16 | public class JTestLTTngLog4j2 { | |
17 | ||
18 | /** | |
19 | * Application start | |
20 | * | |
21 | * @param args | |
22 | * Command-line arguments | |
23 | * @throws IOException | |
24 | * @throws InterruptedException | |
25 | */ | |
26 | public static void main(String args[]) throws IOException, InterruptedException { | |
27 | ||
28 | Logger console = LogManager.getLogger("console-event-1"); | |
29 | Logger lttng = LogManager.getLogger("log4j2-event-1"); | |
30 | Logger lttng2 = LogManager.getLogger("log4j2-event-2"); | |
31 | ||
32 | int nrIter = Integer.parseInt(args[0]); | |
33 | int waitTime = Integer.parseInt(args[1]); /* milliseconds */ | |
34 | int fire_debug_tp = 0; | |
35 | int fire_second_tp = 0; | |
36 | ||
37 | if (args.length > 2) { | |
38 | fire_debug_tp = Integer.parseInt(args[2]); | |
39 | } | |
40 | if (args.length > 3) { | |
41 | fire_second_tp = Integer.parseInt(args[3]); | |
42 | } | |
43 | ||
44 | console.info("CONSOLE only event."); | |
45 | ||
46 | for (int iter = 0; iter < nrIter; iter++) { | |
47 | lttng.info("LOG4J2 INFO tp fired!"); | |
48 | if (fire_debug_tp == 1) { | |
49 | /* Third arg, trigger debug TP. */ | |
50 | lttng.debug("LOG4J2 DEBUG tp fired"); | |
51 | } | |
52 | Thread.sleep(waitTime); | |
53 | } | |
54 | ||
55 | if (fire_second_tp == 1) { | |
56 | lttng2.info("LOG4J2 INFO second logger fired"); | |
57 | } | |
58 | } | |
59 | } |