Backend Development 7 min read

TLog: Lightweight Log Tagging for Microservice Traceability and Quick Integration

TLog provides a non‑intrusive, storage‑free solution for microservice log tracing by automatically tagging logs with a TraceId that propagates across services, supporting major logging and RPC frameworks and enabling rapid integration with Spring Boot in about ten minutes.

Architect's Tech Stack
Architect's Tech Stack
Architect's Tech Stack
TLog: Lightweight Log Tagging for Microservice Traceability and Quick Integration

TLog: What Problems It Solves

With the rise of microservices, many companies split systems into many services, making log tracing across services difficult.

People often consider distributed tracing systems like SkyWalking or Pinpoint, which follow OpenTracing and are non‑intrusive, but setting them up requires time and storage resources.

Full‑volume trace collection can demand an Elasticsearch cluster of at least five nodes, leading to high server and disk costs, especially when dozens of gigabytes are generated daily.

If a company already uses a distributed tracing system, TLog is not applicable.

TLog offers a lightweight solution: it does not collect logs nor require extra storage; it simply tags logs with a TraceId that propagates through the whole microservice call chain, providing upstream and downstream node information. It is suitable for small‑to‑medium enterprises that need a quick solution.

We have adapted TLog to the three major logging frameworks and to Dubbo, Dubbox, and Spring Cloud RPC frameworks; integration can be done in about ten minutes.

Project Features

Lightweight microservice log tracing via log tagging

Non‑intrusive design, simple usage, can be integrated in 10 minutes

Supports Log4j, Log4j2, Logback with automatic detection and adaptation

Supports Dubbo, Dubbox, Spring Cloud RPC frameworks

Customizable tag templates with multiple system‑level tags

Provides spanId to indicate the position of a call in the trace tree

Method‑level custom tag injection

Native support for asynchronous thread tracing

Almost no performance overhead

Quick Start

TLog provides a Spring Boot starter; only two steps are needed to integrate.

Dependency

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

The JAR is already published to Maven Central.

Log Framework Adaptation

Add a single line in your Spring Boot application class to let TLog automatically detect and enhance the used log framework.

@SpringBootApplication
public class Runner {
    static { AspectLogEnhance.enhance(); } // log enhancement, auto‑detect framework

    public static void main(String[] args) {
        SpringApplication.run(Runner.class, args);
    }
}

The enhancement uses Javassist to modify bytecode before the log framework classes are loaded; therefore the static block must be placed before any logger definitions.

RPC Framework Adaptation

In a Spring Boot environment TLog automatically detects the RPC framework (Dubbo, Dubbox, Spring Cloud) and applies the appropriate adaptation.

Result

After the two steps, the application is ready. Example logs for a Dubbo + Logback consumer:

2020-09-16 18:12:56,748 [WARN] [TLOG] Re‑generated traceId[7161457983341056] >> com.yomahub.tlog.web.TLogWebInterceptor:39
2020-09-16 18:12:56,763 [INFO] <7161457983341056> logback-dubbox-consumer:invoke method sayHello,name=jack >> com.yomahub.tlog.example.dubbox.controller.DemoController:22
2020-09-16 18:12:56,763 [INFO] <7161457983341056> test log aaaa >> com.yomahub.tlog.example.dubbox.controller.DemoController:23
2020-09-16 18:12:56,763 [INFO] <7161457983341056> test log bbbb >> com.yomahub.tlog.example.dubbox.controller.DemoController:24

Provider logs show the same TraceId, confirming that each request carries a globally unique identifier across services.

Project Repository

Official site: https://yomahub.com/tlog

JavamicroservicesloggingSpring BoottraceabilityTLog
Architect's Tech Stack
Written by

Architect's Tech Stack

Java backend, microservices, distributed systems, containerized programming, and more.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.