我是登录新手。我正在尝试登录文件。我logback.xml
的是:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>d:/walknshine.log</File>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} -
%msg%n
</Pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>d:/walknshine.%i.log.zip
</FileNamePattern>
<MinIndex>1</MinIndex>
<MaxIndex>10</MaxIndex>
</rollingPolicy>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>1MB</MaxFileSize>
</triggeringPolicy>
</appender>
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
日志记录发生在控制台中,但在给定路径上没有生成文件。我的 Maven 依赖项是
<!-- LOGGING DEPENDENCIES - LOG4J -->
<dependency>
<groupId>logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>logback</groupId>
<artifactId>sl4j</artifactId>
<version>1.6.0</version>
</dependency>
我将记录器用作:
private static final Logger logger = LoggerFactory
.getLogger(Main.class);
logger.info("Logged Message");
请帮帮我......我错过了什么?