今天寫的項目報異常:java
No log4j2 configuration file found. Using default configuration: logging only errors to the console。apache
解決辦法是:maven
方法1、添加log4j2.xml在src目錄下(maven項目在src/main/resources),內容以下:spa
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="WARN"> <!-- Author: Crunchify.com --> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" /> </Console> <RollingFile name="RollingFile" filename="log/CrunchifyTest.log" filepattern="${logPath}/%d{YYYYMMddHHmmss}-fargo.log"> <PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss} [%t] %-5p %c{1}:%L - %msg%n" /> <Policies> <SizeBasedTriggeringPolicy size="100 MB" /> </Policies> <DefaultRolloverStrategy max="20" /> </RollingFile> </Appenders> <Loggers> <Root level="info"> <AppenderRef ref="Console" /> <AppenderRef ref="RollingFile" /> </Root> </Loggers> </Configuration>
方法2、直接在Run configuration-->Arguments-->VM arguments 裏添加:code
-Dorg.apache.logging.log4j.simplelog.StatusLogger.level=OFFxml