Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
Run Trivial.java Example in logging-log4j-1.2.14.zip
How to run the Trivial.java example program in logging-log4j-1.2.14.zip? I have log4j-1.2.14.zip installed at \fyicenter\logging-log4j-1.2.14 folder.
✍: FYIcenter.com
Trivial.java is an example program provided in the logging-log4j-1.2.14.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\logging-log4j-1.2.14\examples folder:
/*
* Copyright 1999-2005 The Apache Software Foundation.
...
*/
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 \local\logging-log4j-1.2.14 \lccal\logging-log4j-1.2.14>java -version java version "1.7.0_45" \local\logging-log4j-1.2.14>javac -cp .;dist\lib\log4j-1.2.14.jar examples\Trivial.java \local\logging-log4j-1.2.14>java -cp .;dist\lib\log4j-1.2.14.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
⇒ Download and Install logging-log4j-1.2.13.zip
2015-12-02, ∼2372🔥, 0💬
Popular Posts:
What Is poi-ooxml-5.2.3.jar? poi-ooxml-5.2.3.jar is one of the JAR files for Apache POI 5.2.3, which...
Saxon-HE (home edition) is an open source product available under the Mozilla Public License. It pro...
JDK 17 java.compiler.jmod is the JMOD file for JDK 17 Compiler module. JDK 17 Compiler module compil...
JDK 17 java.xml.crypto.jmod is the JMOD file for JDK 17 XML (eXtensible Markup Language) Crypto modu...
How to read XML document from socket connections with the socket\DelayedInput.java provided in the A...