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:
Log4JLogger Logger and log4j.properties File
How to use Log4JLogger Logger and log4j.properties File?
✍: FYIcenter.com
The suggested way to use the Log4JLogger Logger and log4j.properties File is to do the following:
1.Create commons-logging.properties file with one entry:
# commons-logging.properties org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
2.Create log4j.properties file:
# log4j.properties # Copyright (c) 2016 FYIcenter.com # Set log level and define my appender log4j.rootLogger=TRACE, MyConsole # Configure my appender log4j.appender.MyConsole=org.apache.log4j.ConsoleAppender log4j.appender.MyConsole.layout=org.apache.log4j.PatternLayout log4j.appender.MyConsole.layout.ConversionPattern=%-4r %-5p [%t] %37c %3x - %m%n
3. Download and install Log4j JAR at C:\local\log4j-1.2.17\log4j-1.2.17.jar. Add Log4j JAR to the JVM class path.
4. Run the HelloCommonsLogging example code with both properties files in the current folder, which is included in the class path:
C:\fyicenter>java -cp .;C:\local\commons-logging-1.2\commons-logging-1.2.jar; C:\local\log4j-1.2.17\log4j-1.2.17.jar HelloCommonsLogging Log class: org.apache.commons.logging.impl.Log4JLogger 0 FATAL [main] MyLogging - Hello - fatal 16 ERROR [main] MyLogging - Hello - error 16 WARN [main] MyLogging - Hello - warn 16 INFO [main] MyLogging - Hello - info 16 DEBUG [main] MyLogging - Hello - debug 16 TRACE [main] MyLogging - Hello - trace
⇒ FAQ for Apache commons-logging.jar
⇐ Jdk14Logger Logger and logging.properties File
2016-11-16, 3489🔥, 0💬
Popular Posts:
JDK 11 jdk.dynalink.jmod is the JMOD file for JDK 11 Dynamic Linking module. JDK 11 Dynamic Linking ...
Java Advanced Imaging (JAI) is a Java platform extension API that provides a set of object-oriented ...
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms, it was develo...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
What Is mail.jar of JavaMail 1.3? I got the JAR file from javamail-1_3.zip. mail.jar in javamail-1_3...