我刚刚从 log4j 1.x 更新到 log4j2。在第一个版本中,一切都运行良好。现在更新到 log4j2 后它没有记录任何东西。我在下面粘贴我的代码。任何人请帮帮我
这是我的依赖项
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
<version>2.0-beta9</version>
<type> jar</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0-beta9</version>
<type> jar</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0-beta9</version>
<type> jar</type>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jcl</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0-beta9</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-taglib</artifactId>
<version>2.0-beta9</version>
</dependency>
这是我的 log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
<Appenders>
<console name="Console" target="SYSTEM_OUT" includeLocation="true">
<PatternLayout pattern="%d %-5p [%t] [%c:%L] %m%n"/>
</console>
<RollingRandomAccessFile name="Rolling" fileName="${sys:DOC_ROOT}/logs/UILogs-${sys:SERVER_NAME}-${sys:SERVER_ID}-${sys:SERVER_TYPE}.log"
filePattern="${sys:DOC_ROOT}/logs/UILogs-${sys:SERVER_NAME}-${sys:SERVER_ID}-${sys:SERVER_TYPE}-%d{yyyy-MM-dd}.log.gz">
<PatternLayout pattern="%d %-5p [%t] [%c:%L] %m%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<SizeBasedTriggeringPolicy size="250 MB"/>
</Policies>
<DefaultRolloverStrategy max="180" compressionLevel="9"/>
</RollingRandomAccessFile>
<Async name="dev">
<AppenderRef ref="DevSMTP" level="fatal"/>
<AppenderRef ref="Console" level="debug"/>
<AppenderRef ref="Rolling" level="debug"/>
</Async>
<Async name="test">
<AppenderRef ref="TestSMTP" level="fatal"/>
<AppenderRef ref="Console" level="debug"/>
<AppenderRef ref="Rolling" level="debug"/>
</Async>
<Async name="prod">
<AppenderRef ref="ProdSMTP" level="fatal"/>
<AppenderRef ref="Console" level="info"/>
<AppenderRef ref="Rolling" level="info"/>
</Async>
<Async name="local">
<AppenderRef ref="DevSMTP" level="fatal"/>
<AppenderRef ref="Console" level="debug"/>
<AppenderRef ref="Rolling" level="debug"/>
</Async>
<Async name="">
<AppenderRef ref="ProdSMTP" level="fatal"/>
<AppenderRef ref="Console" level="info"/>
<AppenderRef ref="Rolling" level="info"/>
</Async>
<Async name="">
<AppenderRef ref="TestSMTP" level="fatal"/>
<AppenderRef ref="Console" level="debug"/>
<AppenderRef ref="Rolling" level="debug"/>
</Async>
<Async name="">
<AppenderRef ref="ProdSMTP" level="fatal"/>
<AppenderRef ref="Console" level="info"/>
<AppenderRef ref="Rolling" level="info"/>
</Async>
<Async name="lib">
<AppenderRef ref="Console" level="info"/>
<AppenderRef ref="Rolling" level="info"/>
</Async>
</Appenders>
<Loggers>
<Root level="debug" additivity="false">
<AppenderRef ref="${sys:SERVER_TYPE}"/>
</Root>
<root level="error">
<appender-ref ref="Console"/>
</root>
<Logger name="org.apache.ibatis" additivity="false">
<AppenderRef ref="lib"/>
</Logger>
<Logger name="java.sql" additivity="false">
<AppenderRef ref="lib"/>
</Logger>
<Logger name="RollingRandomAccessFile" additivity="true">
<AppenderRef ref="Rolling"/>
</Logger>
<logger name="com.foo.Bar" level="trace">
<appender-ref ref="Console"/>
</logger>
</Configuration>