Before using log4j is to take someone else to write good use, today carefully looked under how to configure. Http://blog.sina.com.cn/s/blog_5ed94d710101go3u.html#################################################################################① configures the root logger with the following syntax:##log4j. Rootlogger = [Level],appendername,appendername2,...#level是日志记录的优先级, divided into Off,
LOG4J is an Apache open source project that uses log4j to control log information delivery destinations for consoles, files, databases, GUI components, even socket servers, NT Event loggers, UNIX Syslog daemons, and more ; Can control the information content and information output format of each log; By defining the level of each log information, we are able to control the log generation process more carefu
Testlog4j {public
static void Main (string[] args) {
log.info ("Hello World");
}
}
second, the key to explain the meaning of the log4j configuration2.1 First a copy of the main configuration item description
1. Configure Root Logger
Syntax: Log4j.rootlogger = [level], appenderName1, appenderName2,...
Level: Defines the global log output levels, but the specific output level priority configured in the output destination configuration is
Apache log4j Study Notes:Http://www.cnblogs.com/TopZhujia/archive/2010/05/15/1789993.html
(Xml configuration file)
Below, the configuration file is Properties
Commons-logging + log4j Getting Started Guide [ZT] Original: Zhuang Xiaoli (liigo)Www.liigo.com2005-8-13
Why do I use both commons-logging and log4j? Why not only use one of them?The purpose of commons-Lo
log4j configuration file is causing it.Add the Log4j.xml under Classpath and do some configuration.When the configuration is complete, start the output2014-02-25 09:30:31:743[info][com.mchange.v2.log.mlog.2014-02-25 09:30:31:780[info][com.mchange.v2.c3p0.c3p0registry.banner (c3p0registry.java:204)]-Initializing c3p0-0.9.1.2 [built 21-may-2007 15:04:56; debug true; Trace:10]This means that the response is n
Integration principles of slf4j and Jul, log4j1, log4j2 and LogbackSlf4jLet's start with a simple use case to explain2.1 Simple Use Casesprivate static Logger Logger=loggerfactory.getlogger (Log4jslf4jtest.class);public static void Main (string[] args) {if (logger.isdebugenabled ()) {Logger.debug ("slf4j-log4j debug Message");}if (logger.isinfoenabled ()) {Logger.debug ("slf4j-log4j info message");}if (logg
Log4j is a common log output tool in Java. The original intention of Log4j naming is what Log for Java means. Although JDK has provided a Log API since 1.4, so far, I have never seen anyone use the Log API that comes with JDK. However, using Log4j for development has become a de facto standard.
Log4j is divided into th
(Conversion) log4j: WARN No appenders cocould be found for logger solution, log4jappenders
When using Log4j, we always see:
1 log4j:WARN No appenders could be found for logger (org.apache.ibatis.logging.LogFactory).2 log4j:WARN Please initialize the log4j system properly.
This problem occurs because the configuration of our l
) three parts, wherein logger is used to capture log information, layout is used to format the log information, Appender used to define the output source of the log. The specific architecture can participate in: LOG4J is installed in the same way as adding a common. Jar class library file, you can download the relevant package to the official website (http://logging.apache.org/log4j/2.x/), and the differen
good coding, good architecture.
How to write a good debug log record, no doubt, Log4j,slf4j,,logback is one of the necessary choice.
The behavior of the log recorder (Logger) is hierarchical. As shown in the following table:Can be divided into off, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, all, or the level you define. LOG4J recommends using only four levels, fro
4. Configuration
Inserting log requests into the application code requires a lot of pre-planning and final efforts. It is shown that about 4% of the code is used for output.
Therefore, programs of moderate size are embedded with thousands of log output statements. To manage the output status of these logs in a way that does not require manual management, it is imperative to number and standardize the log output.
Log4j is fully configurable in the pro
("error ");Log. debug ("debug ");Log. Warn ("Warn ");Log.info ("info ");Log. Trace ("trace ");System. Out. println ("okok ");}
}
Place a JSP test test-commons-logging.jsp/
You will see the following output in the Tomcat Console
Log4j: warn no appenders cocould be found for logger (COM. softleader. Newspaper. java. opensource. loggingtest ).
The simple configuration of log4j makes log4j more and more applications: the log4j configuration file provides a full set of functions such as output to the console, files, rollback files, sending log emails, output to database log tables, and custom tags. Log4j is enough if you choose one or two of them. rootlogger =
Many diaosi think that log4j is not easy to use because it is not output to the IDE console. Haha, it is actually a disaster caused by configuration. The following describes how to configure log4j to the console step by step,
I believe that log4j's output level and output mode are all known. I will not talk about it here. Let's just look at the code comment:
# All, TRAC
# Note: log4j. the properties file needs to be placed in the WEB-INF/classes directory. #1. log4j has five levels of logger: Fatal 0, error 3, warn 4, INFO 6, and debug 7 (Priority: Debug, then all logs are output) #2. configure the root logger. Its syntax is log4j. rootlogger = debug (priority], appendername (multiple log sources can be output ). #3. configure t
Use log4j to personalize control logs in Javase, as required:
1. Log the log above the warning level to the error log.
2. Log the normal info information into the info log.
3. Log the debug information into trace log.
4.log information as detailed as possible, and the format is easy to read, the key content includes: Package name, class name, method name, call parameters, exception information, error line n
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.