老师,按照你的那个配置文件复制后,在控制台可以打印INFO和error信息,不显示debug信息,在文件中也不显示
来源:3-3 验证配置
一定要变得更好
2020-01-21
logback中的包名也修改了
在控制台中并不显示debug的信息
写回答
1回答
-
翔仔
2020-01-21
同学好,感觉输出的地方配置错了,可以直接复制粘贴我的,修改一些目录适配成你自己的,没问题后,再对比下异同
logback.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration scan="true" scanPeriod="60 seconds" debug="false"> <!-- 定义参数常量 --> <!-- log级别:TRACE<DEBUG<INFO<WARN<ERROR --> <!-- 形式:logger.trace("msg") --> <property name="log.level" value="debug" /> <property name="log.maxHistory" value="30" /> <property name="log.filePath" value="${catalina.base}/logs/webapps" /> <property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" /> <!-- 控制台设置 --> <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>${log.pattern}</pattern> </encoder> </appender> <!-- DEBUG --> <appender name="debugAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 文件路径 --> <file>${log.filePath}/debug.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 文件名称 --> <fileNamePattern>${log.filePath}/debug/debug.%d{yyyy-MM-dd}.log.gz </fileNamePattern> <!-- 文件最大保存历史数量 --> <maxHistory>${log.maxHistory}</maxHistory> </rollingPolicy> <encoder> <pattern>${log.pattern}</pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>DEBUG</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!-- INFO --> <appender name="infoAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 文件路径 --> <file>${log.filePath}/info.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 文件名称 --> <fileNamePattern>${log.filePath}/info/info.%d{yyyy-MM-dd}.log.gz </fileNamePattern> <!-- 文件最大保存历史数量 --> <maxHistory>${log.maxHistory}</maxHistory> </rollingPolicy> <encoder> <pattern>${log.pattern}</pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>INFO</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <!-- ERROR --> <appender name="errorAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 文件路径 --> <file>${log.filePath}/error.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 文件名称 --> <fileNamePattern>${log.filePath}/error/error.%d{yyyy-MM-dd}.log.gz </fileNamePattern> <!-- 文件最大保存历史数量 --> <maxHistory>${log.maxHistory}</maxHistory> </rollingPolicy> <encoder> <pattern>${log.pattern}</pattern> </encoder> <filter class="ch.qos.logback.classic.filter.LevelFilter"> <level>ERROR</level> <onMatch>ACCEPT</onMatch> <onMismatch>DENY</onMismatch> </filter> </appender> <logger name="com.imooc.o2o" level="{log.level}" additivity="true"> <appender-ref ref="debugAppender" /> <appender-ref ref="infoAppender" /> <appender-ref ref="errorAppender" /> </logger> <root level="info"> <appender-ref ref="consoleAppender" /> </root> </configuration>
032020-07-28
相似问题