Commit | Line | Data |
---|---|---|
464c4756 MJ |
1 | /* |
2 | * SPDX-License-Identifier: MIT | |
3 | * | |
4 | * Copyright (C) 2022 EfficiOS Inc. | |
5 | */ | |
6 | ||
7 | import org.apache.logging.log4j.LogManager; | |
8 | import org.apache.logging.log4j.Logger; | |
9 | ||
10 | /** | |
11 | * Example application using the LTTng-UST Java log4j agent. | |
12 | * | |
13 | * <p> | |
14 | * To obtain LTTng trace events, you should run the following sequence of | |
15 | * commands: | |
16 | * </p> | |
17 | * | |
18 | * <ul> | |
19 | * <li>$ lttng create</li> | |
20 | * <li>$ lttng enable-event -l -a</li> | |
21 | * <li>$ lttng start</li> | |
22 | * <li>(run this program)</li> | |
23 | * <li>$ lttng stop</li> | |
24 | * <li>$ lttng view</li> | |
25 | * <li>$ lttng destroy</li> | |
26 | * </ul> | |
27 | * | |
28 | */ | |
29 | public class HelloLog4j2 { | |
30 | ||
31 | private static final Logger logger = LogManager.getLogger(HelloLog4j2.class); | |
32 | ||
33 | /** | |
34 | * Application start | |
35 | * | |
36 | * @param args Command-line arguments | |
37 | */ | |
38 | public static void main(String args[]) { | |
39 | ||
40 | /* Trigger some tracing events using the Log4j Logger created before. */ | |
41 | logger.info("Basic config: Hello World, the answer is " + 42); | |
42 | logger.info("Basic config: Another info event"); | |
43 | logger.error("Basic config: An error event"); | |
44 | } | |
45 | } |