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,trace,debug,info,wa
Log4j log Configuration
1. Configure the root logger:
Log4j. rootlogger = [level], appendername, appendername2
Level: the log level, which specifies the importance of the log information. It can be divided into four types: All
Debug (Object message );
Info (Object message );
Warn (Object message );
Error (Object message );
If the set level is info, logs with a
, thread, category, etc.) of the logConfiguration mode:Log4j.appender.appenderName.layout =classnameLog4j.appender.appenderName.layout.Option1 = value1...Log4j.appender.appenderName.layout.OptionN = ValuenSecond, configuration detailedIn the actual application, in order to make the log4j run in the system, the configuration file must be set beforehand. The
configuration file of log4j. When the program starts, the log4j component reads log4j. properties, which is similar to reading common configuration files. Obtain the log4j attribute values configured by the user. Call the desired
, thread, category, etc.) of the logConfiguration mode:Log4j.appender.appenderName.layout =classnameLog4j.appender.appenderName.layout.Option1 = value1...Log4j.appender.appenderName.layout.OptionN = ValuenSecond, configuration detailedIn the actual application, in order to make the log4j run in the system, the configuration file must be set beforehand. The
From: http://dingjun1.javaeye.com/blog/413993
Reprinted:
Http://wangjc-opal.javaeye.com/blog/309924
There is no doubt about the powerful functions of log4j, but in actual applications, it is inevitable that an independent log file needs to be output for a function. How can we separate the required content from the original log, what about creating a separate log file? In fact, you can easily implement this function with a slight
Log4j introduction:
Log4j is a powerful logging tool that records operation information in the system and helps administrators analyze and manage related data in the background. You can record the data console, files, interface servers, and GUI components. You can configure or flexibly record the log format through your own configuration to achieve data analysis
The WebService written in Java is used to establish a database connection because the WebService interface is intended for many users. In this case, if you write the database connection statement in our method called by the user, you can use the method before closing it. However, with the Tomcat connection pool, 25 connections can be applied for at most 50 (both 25 and 50 can be configured) at the beginning, saving a lot of time for creating and disabling connections, better compression capabili
The log4j. properties configuration file is described as follows:
# Set root logger level to debug and its only appender to A1
# Log4j has five levels of logger
# Fatal 0
# Error 3
# Warn 4
# INFO 6
# Debug 7
Configure the root logger with the Syntax:
# Log4j. rootlogger = [level], appendername, appendername ,...
The log4j. properties configuration file is described as follows:
# Set root logger level to debug and its only appender to A1
# Log4j has five levels of logger
# Fatal 0
# Error 3
# Warn 4
# INFO 6
# Debug 7
Configure the root Logger with the Syntax:
# Log4j. rootlogger = [level], appendername, appendername ,...
The configuration fails according to many configuration steps on the Internet. Now let's look back at the inconsistency of most versions.
In addition, log4j is flexible in addition to managing logs for the entire container, it can also manage logs for a project. If there are only logs in the container, what should we do with the logs in JUnit? Therefore, project
In general, some important logs in our project want to be output to the specified file separately, instead of the total output to the System Log File. Therefore, log4j provides us with this function, next, let's take a step-by-step look at how it works. This is written in the property configuration mode. The XML method is similar. For more information, see the of
configure log4j with XML or Java at run time, the properties file is useful.
Log4j.rootlogger=info, stdout
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
# to output the caller ' s file name and line number.
log4j.appender.stdout.layout.conversionpattern=%5p [%t] (%f:%l)-%m%n
Analyze:
First line, configure Log4j.rootlogger you know. It sho
Appenders configuration of log4j, log4jappenders
Because log4j was used at the beginning, many configuration items were not understood and recorded.
The following is a log4j. xml configuration
Og4j Advanced Tips-Location of dynamic configuration log output files
The usual use of log4j is to write the output file directly to death in its configuration file (XML or properties), which in many cases is very simple and effective. The disadvantage of this is that if you want this Web application to run, you have
Spring Oauth2 In most cases is still not used, the main use is spring+springmvc+hibernate, sometimes with springsecurity, therefore, This article and the future article example will not contain the OAUTH2 configuration, need to put the former Applicationcontext-security.xml and Pom.xml plus on it, this article in the "ssh+spring Security building methods and example "the article is based on a number of adjustments, the main content is: Configure Sprin
First, a new log4j.properties file can be created in the classes of the project; In the actual programming, in order to make the log4j really run in the system in advance also to define the configuration file. The defining step is to use the logger, Appender, and layout separately. LOG4J supports two configuration file
First, a new log4j.properties file can be created in the classes of the project; In the actual programming, in order to make the log4j really run in the system in advance also to define the configuration file. The defining step is to use the logger, Appender, and layout separately. LOG4J supports two configuration file
OG4J specific output information level configuration method
The log4j configuration file (Configuration file) is used to set the level, the repository, and the layout of the logger, and it can be set in key=value format or in XML format information. By configuring, you can c
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.