Configuring log4j monitoring and file mapping and related settings in Web. xml
Web. XML code
Content configuration and parsing of log4j.properties
# Debug,info,warn,error,fatal Log level
log_level=info
log4j.rootlogger=${log_level},console,file
# LOG4J encoding format, time format settings
Log4j.appender.console=org.apache.log4j.consoleappender
Log4j.append
log4j Introduction log4j has three main components: loggers (Logger), appenders (output source), and layouts (layout). This can be simply understood as the log category, where the logs are to be exported and how the logs are exported. The combined use of these three components makes it easy to record the type and level of information, and to control the style and
Take dailyrollingfileappender as an example: assume that one log file is generated every day.The following settings are available:
Log4j. appender. A1 = org. Apache. log4j. dailyrollingfileappenderLog4j. appender. a1.file = app. LogLog4j. appender. a1.datepattern = '. 'yyyy-mm-ddLog4j. appender. a1.layout = org. Apache. log4j
Configuring log4j is relatively straightforward, such as logging of this mapper interface needs to be logged:Package Org.mybatis.example;public interface Blogmapper {@Select ("select * FROM blog WHERE id = #{id}") Blog Selectblog (int id);}As long as a file named log4j.properties is created in the app's classpath, the specific contents of the file are as follows:# Global Logging Configurationlog4j.rootlogger=error, stdout# MyBatis logging configuratio
I. About log 1, log definition: Information generated by the project during the run Phase 2, the log level most common log level has 4: Error: warn: Warning Log info: Process log debug: Debug
Creating a web project and other configurations is not described here. In future articles, we will introduce the use of the web project framework. here we will only describe how to use log4j in a web project (my server is atat6.0 and IDE is myeclipse)
1. Download log4j. jar, add to WEB-INF/lib, and introduce to libraries of the project
2. Create log4j. xml under
#all logger output level is ' ERROR ' and output position are STDOUT#SO only write our project ' DEBUG log and ERROR log of T He otherslog4j.rootlogger=error, stdout, R#log4j.appender is set output Postion#log4j.logger are set some package (some pack Age your want output logger specially) =[output level],[...output position] #log4j. Logger.org.springframework=off
Log level Size: DEBUG
1, the use of Log4j.rootlogger
#log4j. Rootlogger is configured with an output #log4j that is greater than or equal to the current level of log information. Rootlogger Usage: (note appendername can be one or more) #log4j. Rootlogger =
log4j. Appender. A.layout=org.apache.log4j.patternlayout log4j. Appender. a.layout.conversionpattern=%d{Yyyy-mm-dd Hh\:mm\:ss} |%m%nSolution SolutionsThe problem is that the path of the log file is configuredFile path to specify an absolute path cannot specify a relative pathConfigured as a relative path, the corresponding l
Tomcat under the use of log4j take over catalina.out log file generation, storage by day, solve catalina.out log file too big problem 1. Prepare jar Package:
Log4j-1.2.17.jar (download from http://www.apache.org/dist/logging/log4j/1.2.17/)
Tomcat-juli.jar,
Tomcat-juli-adapte
log4j log File configuration
------------------------------------------------------------------------
first, the log device configuration
# root Logger (other logs are inherited from this logger)
# Default Level=debugLog4j.rootlogger=info, A1, A2 (a1,a2 for Appender)
# Level of the log
Log4j.logger.a=info,a1
Log4j.logg
It has been a while since you used log4j for log output in spring, but sometimes you find that log files are already stored according to their ideals, but there are some baffling project log files that appear in Tomcat (because the project's log files are named after the pro
Write Log two purposes: development phase of debugging, on-line phase tracking System bugs------General code consumption of 4%
What is the difference between log technology and traditional System.out? The log is divided into levels to control whether information is exported to the log file
First of all, these two are log systems.Just slf4j is a simple façade log system simply to provide some column log interfaces without a specific implementation similar to JDBC but simpler than JDBC becauseIt does not need to load the driver to add only its specific package. And log4j himself alone can be a complete
Message that specifies information that can highlight the operation of an application at a coarse-grained level
OFF
This is the highest level, in order to turn off logging
TRACE
Specify less granular information events than debug
WARN
Specify a situation that is potentially harmful
How does the log level work?Level p levels use Q when logging requests are logged, if P>=Q is e
Note: this information is searched through the network and then sorted into
First of all, to explain the parameters of the configuration file, so that the configuration can be reasonable.
Description of parameter meaning:
Configure Root Logger
Its syntax is:
Log4j.rootlogger = [level], appenderName1, appenderName2, ...
Level: Is the priority of the logging, divided into
the levels you define by off, FATAL, ERROR, WARN, INFO, DEBUG, all, or a person. LOG4
=org.apache.log4j.patternlayoutLog4j.appender.file.layout.conversionpattern=[framework]%d-%c-%-4r [%t]%-5p%c%x-%m%nNote: The above example prints log log information to the console and F:/log4j/file.log files. Simple properties such as append control whether the log is overwritten, Conversionpattern is the format of th
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.