1. Download Log4j.jar on the official website2. Copy the Log4j.jar to the Web-info/lib folder.3. Create the Log4j.properties file and store it in the SRC root directory.Fill in the following file information:log4j.rootlogger=info, serverdailyrollingfile, stdout log4j.appender.ServerDailyRollingFile= Org.apache.log4j.DailyRollingFileAppender #每天一个日志文件log4j. Appender.ServerDailyRollingFile.DatePattern= '. ' yyyy-mm-dd log4j.appender.ServerDailyRollingF
Sometimes it is necessary to output a class or a packet's log information separately to monitor the operation of the Code, in fact log4j can be done, the following configuration can be (. Properties configuration file):
Note: For additional information on log4j please refer to http://www.cnblogs.com/ITEagle/archive/2010/04/23/1718365.html, do not repeat here.
###
Tags: ogg user utf-8 Primary Auto method values base weightI. Pre-conditions The system must be log managed using log4j, otherwise the method is invalid. The system must contain the Commons-logging-xxx.jar,log4j-xxx.jar two jar packages, XXX is the version number. Second, the Operation procedure 1. Create a log table T
WORKAROUND: Set the encoding format to: UTF-8, such as red font.
#定义DEBUG优先级, r log4j.rootlogger=debug,file for log output purpose#设置日志输出类型, for file type#log4j. Appender.file=org.apache.log4j.fileappender#设置日志输出类型, a file a dayLog4j.appender.file=org.apache.log4j.dailyrollingfileappender#在每天产生的文件后面追加Log4j.appender.file.DatePattern = '. ' YyyyMMdd#设置日志文件名/home/weblogic/oneboss/0068_stat.logLog4j.appender
The Tomcat default log is to use Commons.logging, and the following example describes the configuration of the log4j log in tomcat6.0.18. Tomcat default is also the output log log, can be the Conf folder logging.properties Delete or change a different name, the original
because the Tomcat catalina.out log is not automatically segmented,
one, the need for log segmentation in the vicinity of the package
1, the compression package has three Jar packs: Log4j-1.2.16.jar Tomcat-juli-adapters.jar Tomcat-juli.jar
Note: If not TOMCAT7 version, please go to the official website to download the corresponding version of the Tomcat-juli.
Learning URL 1:http://www.cnblogs.com/licheng/archive/2008/08/23/1274566.htmlFirst, fast start1. Download log4j compression package, local pressurizationCreate a new Java project in the 2.Eclipse development tool, right-click the project select Properties to open the Properties window for the current project, select the Java Build Path >> library (libaries) > > Add an external jar (add External JARs) to add the Log4j.jar package you just downloaded to
How to write information to a different log file in log4jHave you ever wondered why we used:Logger Logger = Logger.getlogger (Abc.class);To get logger?Rather than just looking at someone's demo, the demo is a simple introductory example of the Hello world level, and we need to know how the API describes them.Logger.getlogger () Unless you use a class to use a string as a parameter, it means "you can give your Logger an arbitrary name, not a class name
Let the console log color highlighted below, is divided into two situations.
One. In the Eclipse console
At this point, the simpler way of implementation. No other tool classes are required.
The warn,error,fatal level is displayed in red. Debug,info, default color
Log4j.xml
Package com.errout;
Import Org.apache.log4j.Logger;
public class Testerrout {
private static final Logger Logger = Logger.getlogger (testerrout.class);
public static
Recently with the Thymeleaf template engine, found that the SQL log output is not, the general SSM framework is not a problem, can output SQL log, but after using the Thymeleaf engine, it is found to use.Now find a workaround,Importing JAR Packages The SQL output configuration is added to the Mybatis.xml file. Log4j and thymeleaf combine to cause SQL
It can be divided into off, fatal, error, warn, info, debug, all, or your defined level.
We recommend that you use only four levels of log4j. The priority ranges from high to low: error, warn, info, and debug. By defining the level here, you can control the switch to the corresponding level of log information in the application.If a log request with a level of P
After the project is deployed in WebLogic, the log4j log for the project is not printed. Because WebLogic set up the log4j log yourself, changing the log4j print output log method is:
Editing the%weblogichome%\user_project\domain
HibernateLog4j.logger.org.hibernate.tool.hbm2ddl=debugLog4j.logger.org.hibernate.engine.transaction=debugMybatisAdd the following configuration in the MyBatis configuration1 Settings > 2 name= "Logimpl" value= "log4j"/>3 settings>Add the following configuration in spring's sqlsessionfactory configuration1 BeanID= "Sqlsessionfactory"class= "Org.mybatis.spring.SqlSessionFactoryBean">2 Propertyname= "Configuration">3 Beanclass= "Org
Org.apache.log4j.jdbc.JDBCAppender is using the traditional JDBC connection method, this way to connect the database inefficient, in order to solve this problem, now customize a log4j Appender, the database connection to the form of connection pooling, this Appender inherits from Org.apache.log4j.jdbc.JDBCAppender and uses the Open source project Poolman (available from Http://nchc.dl.sourceforge.net/project/poolman /poolman/poolman-2.1-b1/poolman-2.1
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.