标签:ges manual int ram roo get tor inter and
https://logback.qos.ch/manual/index.html
Logback is built upon three main classes: Logger
, Appender
and Layout
. These three types of components work together to enable developers to log messages according to message type and level, and to control at runtime how these messages are formatted and where they are reported.
The Logger
class is part of the logback-classic module. On the other hand, the Appender
and Layout
interfaces are part of logback-core. As a general-purpose module, logback-core has no notion of loggers.
Logger是老板,是项目经理,是小组长,他们记录日志,功劳是他们的。
Appender是程序员,是码农,负责干活,熬夜。
Layout是美工。
一个配置例子:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/defaults.xml"/> <!-- 控制台输出 --> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>DEBUG</level> <!-- 日志过滤级别 --> </filter> <encoder> <pattern>%date %-5level [${HOSTNAME} %thread] : %msg%n%n</pattern><!-- 格式化输出 --> <charset>utf8</charset> <!-- 输出编码 --> </encoder> </appender> <!-- 文件输出 --> <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <encoder> <pattern>%date %-5level [${HOSTNAME} %thread] : %msg%n</pattern><!-- 格式化输出 --> <charset>utf8</charset> <!-- 输出编码 --> </encoder> <file>./logs/info1.log</file><!-- 文件存放路径 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>/logs/info/%d{yyyy-MM-dd}.log</fileNamePattern><!-- 每天归档 --> <maxHistory>7</maxHistory><!-- 日志存放周期(天) --> </rollingPolicy> </appender> <!-- 错误日志文件输出 --> <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <level>ERROR</level> <!-- 日志过滤级别 --> </filter> <encoder> <pattern>%date %-5level [${HOSTNAME} %thread] : %msg%n%n</pattern><!-- 格式化输出 --> <charset>utf8</charset> <!-- 输出编码 --> </encoder> <file>./logs/error1.log</file><!-- 文件存放路径 --> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>/logs/error/%d{yyyy-MM-dd}.log</fileNamePattern><!-- 每天归档 --> <maxHistory>7</maxHistory><!-- 日志存放周期(天) --> </rollingPolicy> </appender> <!-- 根日志输出级别 --> <root level="INFO"> <appender-ref ref="CONSOLE"/> </root> <logger name="com.tl.ts.service.impl" level="error" additivity="false"> <appender-ref ref="ERROR_FILE"/> </logger> <logger name="com.tl.ts.service.impl" level="info" additivity="false"> <appender-ref ref="INFO_FILE"/> <appender-ref ref="ERROR_FILE"/> </logger> </configuration>
标签:ges manual int ram roo get tor inter and
原文地址:https://www.cnblogs.com/luohaonan/p/11577389.html