X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=doc%2Fexamples%2Fjava-log4j2-basic%2FHelloLog4j2.java;fp=doc%2Fexamples%2Fjava-log4j2-basic%2FHelloLog4j2.java;h=2aa10260d05d7a057802fc3e5e7c8d973b9f0b3b;hb=464c475658ae29039b3b9e769b5b02195688a94a;hp=0000000000000000000000000000000000000000;hpb=08c1dfc43e014a99cd47202f6b370f8afa33e4c8;p=lttng-ust.git diff --git a/doc/examples/java-log4j2-basic/HelloLog4j2.java b/doc/examples/java-log4j2-basic/HelloLog4j2.java new file mode 100644 index 00000000..2aa10260 --- /dev/null +++ b/doc/examples/java-log4j2-basic/HelloLog4j2.java @@ -0,0 +1,45 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (C) 2022 EfficiOS Inc. + */ + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +/** + * Example application using the LTTng-UST Java log4j agent. + * + *

+ * To obtain LTTng trace events, you should run the following sequence of + * commands: + *

+ * + * + * + */ +public class HelloLog4j2 { + + private static final Logger logger = LogManager.getLogger(HelloLog4j2.class); + + /** + * Application start + * + * @param args Command-line arguments + */ + public static void main(String args[]) { + + /* Trigger some tracing events using the Log4j Logger created before. */ + logger.info("Basic config: Hello World, the answer is " + 42); + logger.info("Basic config: Another info event"); + logger.error("Basic config: An error event"); + } +}