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:
Configuration File for Apache Log4j
How to write a simple configuration file for Apache Log4j? I just want to use the basic functionalities to specify the log file name and the log level.
✍: FYIcenter.com
Below is a simple configuration file, log4j2.xml, that support the Log4j 2 API:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) FYIcenter.com -->
<Configuration status="WARN">
 <Appenders>
  <File name="MyAppender" fileName="HelloLog4j2.log" 
   bufferedIO="true">
   <PatternLayout 
    pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
  </File>
  <Console name="Screen" target="SYSTEM_OUT">
   <PatternLayout 
    pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
  </Console>
 </Appenders>
 <Loggers>
  <Logger name="fyiLogger" level="debug" additivity="true">
   <AppenderRef ref="MyAppender"/>
  </Logger>
  <Root level="error">
   <AppenderRef ref="Screen"/>
  </Root>
 </Loggers>
</Configuration>
This sample configuration file log4j2.xml does the following:
⇒ Running Program with Apache Log4j Configuration
⇐ Running Program with Apache Log4j
2015-11-11, ∼2589🔥, 0💬
Popular Posts:
What Is poi-scratchpad-3.5.jar? poi-scratchpad-3.5.jar is one of the JAR files for Apache POI 3.5, w...
commons-io-2.6-sources.j aris the source JAR file for Apache Commons IO 2.6, which is a library of u...
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...
Where to get the Java source code for Connector/J 8.0 Core API module? Java source code files for Co...
commons-io-2.6-sources.j aris the source JAR file for Apache Commons IO 2.6, which is a library of u...