Categories:
Audio (13)
Biotech (29)
Bytecode (35)
Database (77)
Framework (7)
Game (7)
General (512)
Graphics (53)
I/O (32)
IDE (2)
JAR Tools (86)
JavaBeans (16)
JDBC (89)
JDK (337)
JSP (20)
Logging (103)
Mail (54)
Messaging (8)
Network (71)
PDF (94)
Report (7)
Scripting (83)
Security (32)
Server (119)
Servlet (17)
SOAP (24)
Testing (50)
Web (19)
XML (301)
Other Resources:
Run Trivial.java Example in log4j-1.2.17.zip
How to run the Trivial.java example program in log4j-1.2.17.zip? I have log4j-1.2.17.zip installed at \fyicenter\apache-log4j-1.2.17 folder.
✍: FYIcenter.com
Trivial.java is an example program provided in the log4j-1.2.17.zip.
It is used to show you how to use Log4j with the default configuration.
Here is the source code of Trivial.java in the \fyicenter\apache-log4j-1.2.17\examples folder:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with ... */ package examples; import org.apache.log4j.Logger; import org.apache.log4j.BasicConfigurator; import org.apache.log4j.NDC; // ... public class Trivial { static Logger logger = Logger.getLogger(Trivial.class); public static void main(String[] args) { BasicConfigurator.configure(); NDC.push("Client #45890"); logger.info("Awake awake. Put on thy strength."); Trivial.foo(); InnerTrivial.foo(); logger.info("Exiting Trivial."); } static void foo() { NDC.push("DB"); logger.debug("Now king David was old."); NDC.pop(); } static class InnerTrivial { static Logger logger = Logger.getLogger(InnerTrivial.class); static void foo() { logger.info("Entered foo."); } } }
You can follow these steps to run the Trivial.java example program:
\fyicenter>cd \fyicenter\apache-log4j-1.2.17 \fyicenter\apache-log4j-1.2.17>java -version java version "1.7.0_45" \fyicenter\apache-log4j-1.2.17>javac -cp log4j-1.2.17.jar examples\Trivial.java \fyicenter\apache-log4j-1.2.17>java -cp .;log4j-1.2.17.jar examples.Trivial 0 [main] INFO examples.Trivial Client #45890 - Awake awake. Put on thy strength. 0 [main] DEBUG examples.Trivial Client #45890 DB - Now king David was old. 1 [main] INFO examples.Trivial$InnerTrivial Client #45890 - Entered foo. 1 [main] INFO examples.Trivial Client #45890 - Exiting Trivial.
The source code and the output shows that:
Â
⇒ Run Sort.java Example in log4j-1.2.17.zip
⇠Configuration Properties File for Apache Log4j 1.x
⇑ Using Apache Log4j 1.x in Java Programs
⇑⇑ FAQ for Apache Log4j
2022-06-22, 2283👍, 13💬
Popular Posts:
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
Jettison is a collection of Java APIs (like STaX and DOM) which read and write JSON. This allows nea...
JDK 11 jdk.xml.dom.jmod is the JMOD file for JDK 11 XML DOM module. JDK 11 XML DOM module compiled c...
What Is jaxb-api-2.1.6.jar? Java Architecture for XML Binding (JAXB) is a Java API that allows Java ...
What Is mail.jar of JavaMail 1.3? I got the JAR file from javamail-1_3.zip. mail.jar in javamail-1_3...