LOG4J2 issues where logs cannot be written to a file under Web engineering

Source: Internet
Author: User

Contact log4j soon before, in the Java Engineering Test study, everything is normal.

A few days ago in a JSP case, Web engineering, the same configuration file, but can not write files.

The normal output in the console log.

Web Engineering, the Java class in the Main method test, you can write the file, the console is also normal.

After repeated testing, the problem is on the path.

The previously used configuration file uses a relative path, and the log output is normal after the absolute path is replaced.

The configuration using an absolute path is as follows, and can be used properly under Web engineering:

<?xml version= "1.0" encoding= "UTF-8"?> <configuration status= "error" > <appenders> <con Sole name= "Console" target= "System_out" > <thresholdfilter level= "Trace" onmatch= "ACCEPT" DEN Y "/> <patternlayout pattern="%d{hh:mm:ss. SSS}%-5level%class{36}%l%m-%msg%xex%n "/> </Console> <file name=" log "filename=" f:/edu Tohome/edutohome/log/test.log "append=" false "> <patternlayout pattern="%d{hh:mm:ss. SSS}%-5level%class{36}%l%m-%msg%xex%n "/> </File> <file name=" ERROR "Filename=" f:/edutohome/
            Edutohome/logs/error.log "> <thresholdfilter level=" error "onmatch=" ACCEPT "onmismatch=" DENY "/> <patternlayout pattern= "%d{yyyy. Mm.dd ' at ' HH:mm:ss z}%-5level%class{36}%l%m-%msg%xex%n '/> </File> <rollingfile name= ' R
        Ollingfile "Filename=" F:/edutohome/edutohome/logs/web.log "             filepattern= "f:/edutohome/edutohome/logs/$${date:yyyy-mm}/web-%d{mm-dd-yyyy}-%i.log.gz" > <P Atternlayout pattern= "%d{yyyy-mm-dd ' at ' HH:mm:ss z}%-5level%class{36}%l%m-%msg%xex%n"/> <sizebase Dtriggeringpolicy size= "10MB"/> </RollingFile> </appenders> <loggers> &l T;root level= "Trace" > <appender-ref ref= "rollingfile"/> <appender-ref ref= "Console"/&G
			T <appender-ref ref= "ERROR"/> <appender-ref ref= "log"/> </root> </loggers> </conf Iguration>

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.