Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
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 (309)
Collections:
Other Resources:
Example of Default Apache Commons Logging
Where can I find a Java example code of using the default logger of Apache Commons Logging?
✍: FYIcenter.com
If you running JVM 1.4 or higher,
the default logger of Apache Commons Logging is the
org.apache.commons.logging.impl.Jdk14Logger class.
You can use it without any configuration settings.
Here is simple Java example that uses the default logger of Apache Commons Logging:
// Copyright (c) 2016 FYIcenter.com import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public class HelloCommonsLogging { private static final Log log = LogFactory.getLog("MyLogging"); public static void main(String[] args) { System.out.println("Log class: "+log.getClass().getName()); log.fatal("Hello - fatal"); log.error("Hello - error"); log.warn("Hello - warn"); log.info("Hello - info"); log.debug("Hello - debug"); log.trace("Hello - trace"); } }
You can compile and run the above example in a command window as shown below:
C:\fyicenter>javac -cp C:\local\commons-logging-1.2\commons-logging-1.2.jar HelloCommonsLogging.java C:\fyicenter>java -cp .;C:\local\commons-logging-1.2\commons-logging-1.2.jar HelloCommonsLogging Log class: org.apache.commons.logging.impl.Jdk14Logger Nov 13, 2016 9:44:56 PM MyLogging main SEVERE: Hello - fatal Nov 13, 2016 9:44:56 PM MyLogging main SEVERE: Hello - error Nov 13, 2016 9:44:56 PM MyLogging main WARNING: Hello - warn Nov 13, 2016 9:44:56 PM MyLogging main INFO: Hello - info
Notes that the default logging level is "info". This is why the "debug" and "trace" logging messages are not showing up in the output.
The output also confirms that the default logger is org.apache.commons.logging.impl.Jdk14Logger
⇒ org.apache.commons.logging.Log System Property
⇐ Apache Commons Logging LogFactory.getLog() Method
2017-05-29, 1467🔥, 0💬
Popular Posts:
Java Cryptography Extension 1.6 JAR File Size and Download Location: File name: jce.jar, jce-1.6.jar...
How to download and install Apache ZooKeeper Source Package? Apache ZooKeeper is an open-source serv...
Where to find answers to frequently asked questions on Downloading and Installing Connector/J - JDBC...
What Is poi-scratchpad-5.2.3.jar ?poi-scratchpad-5.2.3.jar is one of the JAR files for Apache POI 5....
jlGui is a music player for the Java platform. It is based on Java Sound 1.0 (i.e. JDK 1.3+). It sup...