1. 程式人生 > >關於ERROR StatusLogger No log4j2 configuration file found. 解決 eclipse報錯

關於ERROR StatusLogger No log4j2 configuration file found. 解決 eclipse報錯

報錯ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

在專案中新建resources資料夾,加入log4j2.xml檔案,如下

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Appenders>
        <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
        </Console>
        <RollingFile name="RollingFile" fileName="logs/strutslog1.log"
                     filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
            <PatternLayout>
                <Pattern>%d{MM-dd-yyyy} %p %c{1.} [%t] -%M-%L- %m%n</Pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy />
                <SizeBasedTriggeringPolicy size="1 KB"/>
            </Policies>
            <DefaultRolloverStrategy fileIndex="max" max="2"/>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Logger name="com.opensymphony.xwork2" level="WAN"/>
        <Logger name="org.apache.struts2" level="WAN"/>
        <Root level="warn">
            <AppenderRef ref="STDOUT"/>
        </Root>
    </Loggers>

</Configuration>
在Run—Run Configurations對應專案的Classpath中選擇User Entries,點選Advanced,選擇Add Folder,把resources資料夾新增進來。