)Org.apache.log4j.DailyRollingFileAppender (Generate a log file every day)Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size)Org.apache.log4j.WriterAppender (send log information in stream format to any specified location)Configuration mode:Log4j.appender.appenderName = ClassNameLog4j.appender.appenderName.Option1 = value1...Log4j.appender.appenderName.OptionN = Valuen3, LayoutsSometimes users want t
category. The minimum width is 20. If the category name is smaller than 20, the "-" sign specifies the left alignment. 3) %. 30C: specify the name of the output category. The maximum width is 30. If the category name is greater than 30, the extra characters on the left will be truncated, but there will be no spaces if the value is less than 30. 4) % Category 30C: If the category name is less than 20, fill in spaces and align right. If the category name is longer than 30 characters, it will be t
Log4j and log (1) Common log4j configuration common log4j configuration, generally two methods can be used ,. properties and. xml. Here are two simple examples: 1. log4j. properties ### set org. level INFO, DEBUG, WARN, ERROR, and
)Org.apache.log4j.DailyRollingFileAppender (Generate a log file every day)Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size)Org.apache.log4j.WriterAppender (send log information in stream format to any specified location)Configuration mode:Log4j.appender.appenderName = ClassNameLog4j.appender.appenderName.Option1 = value1...Log4j.appender.appenderName.OptionN = Valuen3, LayoutsSometimes users want t
Log4j is an open source project for Apache, by using log4j, we can control the destination (console, file, GUI component, even interface server) of the log information, we can control the output format of each log, by defining the level of each log information, We are able to control the log generation process in more detail. Most interesting of all, these can be configured flexibly with a single
) org.apache.log4j.DailyRollingFileAppender (generates a log text per day Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size) Org.apache.log4j.WriterAppender (sends the log information in stream format to any specified location)Configuration mode:Log4j.appender.appenderName = ClassNamelog4j.appender.appenderName.Option1 = value1 ... Log4j.appender.appenderName.OptionN = Valuen3, LayoutsSometimes user
)Org.apache.log4j.DailyRollingFileAppender (Generate a log file every day)Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size)Org.apache.log4j.WriterAppender (send log information in stream format to any specified location)Configuration mode:Log4j.appender.appenderName = ClassNameLog4j.appender.appenderName.Option1 = value1...Log4j.appender.appenderName.OptionN = Valuen3, LayoutsSometimes users want t
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
Configuration of Java log4jLog4j has a lot of advantages, it is very convenient to use, is the configuration of some trouble, the following I introduce LOG4J configuration method.Log4j is used to record logs.The operation of the software can not be separated from the log. Logs are mainly used to record some important o
)Org.apache.log4j.DailyRollingFileAppender (Generate a log file every day)Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size)Org.apache.log4j.WriterAppender (send log information in stream format to any specified location)Configuration mode:Log4j.appender.appenderName = ClassNameLog4j.appender.appenderName.Option1 = value1...Log4j.appender.appenderName.OptionN = Valuen3, LayoutsSometimes users want t
The performance of log4j is much better than that of system.out.println, especially when a large number of output statements are observed.
--------------------------------------------------------------------------------------------------
Download Address:
Current version, 2.0 beta3
Jar:http://www.apache.org/dyn/closer.cgi/logging/log4j/2.0-beta3/apache-log4j-2.0-
project Lib libraryMy project is the project of idea, so Lib is in the directory, but the normal JAVV Web application lib is the web directory2. After placing the jar package, we add a configuration file using log4jPut the configuration file in the Classpath directory, generally our normal situation is placed in the SRC root directory can be?
123456789101112131415161718192021222324252627282930
first, a simple introduction to the use of log4j steps
The whole is divided into the following steps: 1, the introduction of Log4j-*.*jar, the JAR package 2, add a configuration file (Log4j.xml or Log4j.properties), 3, the Packaging Log tool class in the business use. This is the traditional use of the steps, but we can directly with the Lombok wrapped Log too
used to escape characters.2. Location of the log4j. properties File(1) In a Java project, it is placed in the root directory of the project rather than in the src directory of the project.(2) In the javaweb project, it is placed in the src directory, because Tomcat will load it by default, we do not need to manually load the log4j configuration file. We only nee
)Org.apache.log4j.DailyRollingFileAppender (Generate a log file every day)Org.apache.log4j.RollingFileAppender (creates a new file when the file size reaches the specified size)Org.apache.log4j.WriterAppender (send log information in stream format to any specified location)Configuration mode:Log4j.appender.appenderName = ClassNameLog4j.appender.appenderName.Option1 = value1...Log4j.appender.appenderName.OptionN = Valuen3, LayoutsSometimes users want t
known at present.The difference between the two methods:Logfactory from common-logging bag. If using Logfactory.getlog:Pros: You can replace log4j with any logger that implements the universal log interface, and the program is unaffected.Disadvantage: Need one more common-logging package, this is barely a disadvantage.Logger from Log4j's own bag. If using Logger.getlogger:Pros: You only need a log4j jar pa
Use log4j without configuration files
Log4j is an open-source Java program of Apache. It has powerful functions and can be applied to different fields. It supports various types of logs, such as console, file, email, and DB. However, the configuration of log4j must also be
Search on the internet for more than n data, basic are basic configuration and detailed introduction, reproduced too much, but caused us to search the key information more trouble, after a Google and their own debugging, finally succeeded, recorded.
Suppose I need to output the log information in the Com.domain.web.monitor package to ... /logs/a.log, configure the following
#monitor是我们单独配置的com. The appendname of Domain.web.monitor
Log4j.rootlogger=e
Method One, the solution is natural to use the relative path instead of absolute path, in fact log4j Fileappender itself has such a mechanism, such as: Log4j.appender.logfile.file=${workdir}/logs/app.log
where "${workdir}/" is a variable that is replaced by the value "Workdir" in the system property. In this way, we can use System.setproperty ("Workdir", Workdir) before log4j load the
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.