)-This is error messageThe above, even if the log4j is completed the simple use. 2, Output what? Above, we implemented the LOG4J console output, in which there is not much code to use, relatively speaking, need to say is the log4j configuration file. In a common development environment, the use of
see the log, and finally the whole of a complete log4j demo!2. Spring MVC ProjectThe Web project is built with spring MVC, placing log4j.properties in the Src/main/resources conf directory (Web engineering configuration files are usually in the resources or Web-inf directory), Edit Web. Xml to add3. General Web EngineeringWithout the listener load log4j.properti
Today, I made a one-day remote log configuration. Due to the lack of documents and strategies, debugging was very difficult. Most of the items searched on the Internet are only code-based and do not describe the principles at all. Finally, the configuration is successful, and now the process is organized as follows.
Summary: socket-based remote log is composed of the server and client. The server needs to s
Log4j configuration is commonly used. Two methods are generally used:. properties and. xml. The following two simple examples are provided:1. log4j. Properties
### Set Org. level info, debug, warn, error, and output location a1, a2 # log4j.category.org. zblog = error, A1 log4j.category.org. zblog = info, A2
all classes under the Com.neusoft package have a level of debug.You can change the Com.neusoft to the name of the package you used for your project.Log4j.logger.com.opensymphony.oscache=errorLog4j.logger.net.sf.navigator=errorThese two sentences are to set the error level of the two packages to be errors, if there is no configuration Ehcache in the project, you do not need these two sentences.Log4j.logger.org.apache.commons=errorLog4j.logger.org.apac
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 create a log4j running environment. The
4Basic log4j Configuration
Log4j consists of three important components: loggers, appenders, and layouts, which respectively indicate the priority of log information, the output destination of log information, and the output format of log information. Supports key = value format setting or XML format setting.
L the pri
: once where
daysThe programmer decided not to display the System.out.println, but to comment out the spam statements on a line. If where
daysIf you want to debug variable values, you can only remove these comments in a row to recover the SYSTEM.OUT.PRINTLN statement.
Using log4j can be a good treatment for similar situations. Log4j use method The following is a log4j
Log4j configuration is commonly used. Two methods are generally used:. properties AND. xml. The following two simple examples are provided:1. log4j. properties
### Set org. level INFO, DEBUG, WARN, ERROR, and output location A1, A2 # log4j.category.org. zblog = ERROR, A1log4j.category.org. zblog = INFO, A2log4j. append
”);System.setProperty("log4jPrefix",project_name);
You can configure in Web. xml
Log4j. propertites can be configured as follows:
log4j.appender.LogFile.File = logs/${log4jPrefix}_log4j_log.loglog4j.appender.LogFile.Append = truelog4j.appender.LogFile.ImmediateFlush = truelog4j.appender.LogFile.DatePattern=‘.‘yyyy-MM-ddlog4j.appender.LogFile.Threshold = INFOlog4j.appender.LogFile.layout = org.apache.log4
configuration file
LOG4J supports two types of configuration file formats:
1. XML-formatted files
2. File in properties format
You can also configure the LOG4J environment in code without using a configuration file at all. Ho
Basic information:-------------Log4j-1.2.9.jarConfiguration process:------------1) Load log4j-1.2.9.jar2) Configure log4j. properties in the root path. refer to the following log4j configuration code.3) Add the following logging code to the Java file, JSP, or servlet for log
will make your application more flexible.LOG4J supports two configuration file formats, one in XML format and one in the properties format. Here's how to use the properties format as a configuration file:Example:Log4j.rootlogger=info, A1Log4j.appender.a1=org.apache.log4j.consoleappenderLog4j.appender.a1.layout=org.apache.log4j.patternlayoutLOG4J.APPENDER.A1.LAYO
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 ###
, 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
, 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
, 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
, 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
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 create a log4j running environment. The
The previous article on the log4j of the properties of the configuration, although the sense of difference is not very large, but the Log4j.properties configuration method can not use filter filter to limit the log level, another reason is Log4j.xml SQL statements can be placed in the Conversionpattern parameter of the Layout property when the database is inserte
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.