TLog 分布式日志标记追踪神器

TLog是一个轻量级的分布式日志标记追踪神器,自动对日志打标签完成微服务的链路追踪。支持log4j,log4j2,logback三大日志框架,支持dubbo,dubbox,springcloud三大RPC框架

 

springboot依赖

<dependency>
  <groupId>com.yomahub</groupId>
  <artifactId>tlog-all-spring-boot-starter</artifactId>
  <version>1.3.4</version>
</dependency>

 

 

日志框架适配

只需要把layout的实现类换掉就可以了

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
    <property name="APP_NAME" value="logtest"/>
    <property name="LOG_HOME" value="./logs" />
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!--这里替换成AspectLogbackEncoder-->
        <encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
              <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger.%line - %msg%n"</pattern>
        </encoder>
    </appender>
    <appender name="FILE"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>${LOG_HOME}/${APP_NAME}.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>${LOG_HOME}/${APP_NAME}.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
            <maxFileSize>1000MB</maxFileSize>
        </rollingPolicy>
        <!--这里替换成AspectLogbackEncoder-->
        <encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger.%line - %msg%n"</pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="FILE" />
    </root>
</configuration>

 

 

日志效果:

2021-11-03 13:47:50.542 DEBUG 23944 --- [nio-8081-exec-1] c.x.x.controller.HelloController         : [0][9498949733826624] hello xc debug

 

 

官方文档:

https://yomahub.com/tlog/docs

 

posted @ 2021-11-03 13:56  草木物语  阅读(911)  评论(0编辑  收藏  举报