Using log4j to implement log management in Javaweb

Source: Internet
Author: User

1. Download Log4j.jar on the official website

2. 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.ServerDailyRollingFile.File=e:/moneyassist/running.log Log4j.appender.ServerDailyRollingFile.layout=org.apache.log4j.PatternLayout Log4j.appender.ServerDailyRollingFile.layout.ConversionPattern=%d{yyyy-mm-dd HH:mm:ss}%p [%c:%l]%m%n%n# Debug information output format Log4j.appender.ServerDailyRollingFile.Append=true
#追加

4. Call in Java code:

Logger Logger = Logger.getlogger (this. GetClass), Logger.info ("Hello World");

Using log4j to implement log management in Javaweb

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.