The log4j configuration file is used to set the level, the repository, and the layout of the logger, which can be set in key=value format or in XML format. By configuration, you can create a running environment for log4j.Steps to create log4j:
The associated jar package (L
In the Petclinic project, there are several entries in Web.xml that are related to log4j, which are:
1.
2.
3. (The entry is commented out in the Petclinic)
class>org.springframework.web.util.log4jconfiglistenerclass>
We know that log4j is used in web-application, and there are many ways to configure it:
A.
Configure the log4j with a servlet or S
configures the LOG4J environment with the following syntax: /** Basicconfigurator.configure (); Automatically and quickly use the default log4j environment. * Propertyconfigurator.configure (* "D:\\project\\eclipse\\log4j\\src\\log4j.properties"): * Read the properties file using Java The configuration file tha
Yesterday on-line toss a half-day, found that the log is always unable to print correctly to the specified file, but Tomcat catalina.out print the business log, carefully check the online log4j configuration, no problems found, console log input is not open. Then quickly use the last online package to replace the re-release, found that the problem solved.Taking into account the new on-line jar package that
Output the log configuration of java log4j to mysql, log4jmysql
Log4j supports outputting logs to files, databases, and even remote servers. This time I will share with you how to output logs to mysql.
(1)The configuration of log4j. properties is as follows:
Advantages of 1.LOG4JLog4j is an open source project for Apache, by using log4j, we can control the delivery of log information, we can control the output format of each log, and by defining the level of each log information, we can control the log generation process more carefully. Most interesting of all, these can be configured flexibly with a single configuration file without the need to modify the appl
by the QC Problem List page)Log4j.logger.org.springframework=debugThis sentence is spring's package.Log4j.logger.org.hibernate.ps.preparedstatementcache=warnLog4j.logger.org.hibernate=debugThese two sentences are Hibernate's package.The above package settings can be customized according to the actual situation of the project.Three, log4j detailed1. Define the configuration fileLOG4J supports two
Configure log4j log, first import Slf4j-log4j12-1.7.7.jarConfiguring in Maven
When you use the properties file configuration
### set log levels ###
Log4j.rootlogger = debug,d,e LOG4J.APPENDER.D
= Org.apache.log4j.DailyRollingFileAppender
log4j.appender.d.file = ${webapp.root}/logs/common-default.log
Log4j.appender.d.append = True
log4j.appender.d.threshold = INFO
log4j.appender.d.layout = Org.apache.l
Grails uses log4j log information and log4j configuration information is written in Config.groovy files.
One, Grails 1.1 can specify different logging levels for the code under different packages, such as:
log4j = { // 设置控制器和GSP页面的级别为error error 'org.codehaus.groovy.grails.web.servlet', // controllers 'org.codehau
The default log framework provided by hibernate3 is slf4j. The SLF of hibernate3 is only a log interface, while the default log framework provided by hibernate3 is rarely used by companies or projects in actual development, here we record a log framework that uses log4j to replace the implementation of the slf4j log framework. The specific configuration and implementation are as follows:
I. added the
SPRINGMVC+HIBERNATE+LOG4J+SLF4J is used in the application. The log level of the log4j is tuned to info. However, when the Web container (Tomcat) starts and runs, the debug-level logs in the spring,hibernate frame are constantly being brushed, causing the log file to soar and the disk to explode in a few days.
In response to this problem on the Internet to find a lot of methods, are no effect or palliative
Preface
I've been saying, how to read the Log4j profile log4j.properties.
The next discussion is: How to set the path of the log file created in log4j.
Tomcat's okay. For complex WebLogic, this is how to set the path, because it doesn't understand how to press the war file.
In the last article
Also mentioned in the log (log4j)
Log4j is a Java-based open-source log component. log4j has powerful functions. We can output log information to the console, files, and user interfaces, it can also output Event recorders and some system resident processes to the operating system. It is worth mentioning that log4j allows you to easily customize log formats and log levels, and helps developers ful
an agreement better than the configuration
The Convention is better than configuration (Convention over config), also known as convention programming, is a software design paradigm designed to reduce the number of decisions that software developers need to make, and gain simple benefits without sacrificing flexibility. A large number of configuration files, it i
The three main components of the log4j configuration file are:Logger,appender and layout, respectively, log type, log output destination, log output format.Log4j.rootlogger = [Level],appendername, Appendername, ...(Level is the error, Appendername is the output destination, this example is set to MyLog, you can define more than one) level priority is fatal, ERROR, WARN, INFO, DEBUG 5 levels. By defining the
The production of a log in the project is necessary for a project, now used in a more extensive, more popular log tools have log4j; This log tool is actually very convenient to use, and when used, it was created like Java.util.logging.Logger, The JDK log logging information is obtained and exported using the handler object, and the exported information is formatted by formatter object and log4j log informat
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.