Log4j cannot print log to file resolution

Source: Internet
Author: User
Tags log log log4j

Recently made a project, want to print different logs to different files, configured as follows:

Log4j.rootcategory=debug, stdout Log4j.rootlogger=debug, stdout, FILE # # # # stdout # # # log4j.appender.stdout= Org.apache.log4j.ConsoleAppender Log4j.appender.stdout.target=system.out log4j.appender.stdout.layout=
Org.apache.log4j.PatternLayout Log4j.appender.stdout.layout.conversionpattern=%d{absolute}%5p-%m%n # # output File configuration # # #  
Log4j.appender.file=org.apache.log4j.rollingfileappender Log4j.appender.file.append=true Log4j.appender.file.file=./logs/root.log Log4j.appender.file.threshold=debug log4j.appender.FILE.layout= Org.apache.log4j.PatternLayout log4j.appender.file.layout.conversionpattern=%d{yyyy-mm-dd HH:mm:ss} [%5p]-%c-%f (% L)-%m%n LOG4J.APPENDER.FILE.MAXFILESIZE=10MB # # # # # # # # # # # # # Log4j.logger.org.springframework=debug, Spring lo
G4j.logger.org.apache=debug Log4j.logger.org.apache.catalina=debug Log4j.logger.org.apache.commons.digester.digester=debug log4j.logger.org.apache.catalina.startup.tldconfig= DEBUG Log4j.logger.chb.test=debug # # # # Print to the corresponding log log # # # LOG4J.appender.spring=org.apache.log4j.rollingfileappender Log4j.appender.spring.append=true Log4j.appender.spring.file=./logs/spring.log Log4j.appender.spring.threshold=debug log4j.appender.spring.layout= Org.apache.log4j.PatternLayout log4j.appender.spring.layout.conversionpattern=%d{yyyy-mm-dd HH:mm:ss} [%5p]-%c-%f   (%l)-%m%n LOG4J.APPENDER.SPRING.MAXFILESIZE=10MB

Initially define the Rootlog, print to the project Logs/root.log, and then give Org.springframework an individual named Spring, and then print to Logs/spring.log. However, the file is always printed out anyway. Later found to be the file output path problem, must use absolute path.
After this modification

Log4j.appender.file.file=d:/xxx/logs/root.log
Log4j.appender.spring.file=d:/xxx/logs/spring.log

XXX for the corresponding path. To print out the file.

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.