logback 日志输出级别设置
程序员文章站
2022-07-03 16:34:28
...
在公司的项目中用logback做日志输出操作,一个logger日志会同时显示在界面,也会记录到文件.通过仔细阅读官方文档,发现可以在不影响界面的输出情况下改变文件的输出级别.具体如下:
<appender name="DEVICE_MESSAGE_DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/device/message.txt</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>log/device/message-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<maxHistory>10</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>10MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n </pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.dongluhitec.card.hardware" level="INFO">
<appender-ref ref="DEVICE_MESSAGE_DEBUG"/>
</logger>
转载于:https://my.oschina.net/u/436211/blog/648413
上一篇: logback动态设置某个类的日志级别
下一篇: 浏览器的渲染机制