How to Integrate Tinylog into Spring Boot for Lightweight Logging

This tutorial shows how to add the tinylog logging framework to a Spring Boot application by excluding the default logger, adding tinylog dependencies, configuring tinylog.properties, and verifying the setup with a simple Lombok‑based logging example.

Programmer DD
Programmer DD
Programmer DD
How to Integrate Tinylog into Spring Boot for Lightweight Logging

tinylog (https://tinylog.org/v2/) is a lightweight open‑source logging solution that consists of only two JAR files (API and implementation) with a total size of 178 KB and no external dependencies.

Despite its small footprint, it provides complete basic logging management, a familiar API, multiple configurable output options, and excellent performance as shown in the official benchmark.

Integrating tinylog with Spring Boot

Following the usual three‑step process for replacing Spring Boot’s default logging framework, we:

Exclude the default logging starter.

Add the tinylog dependencies.

Provide a tinylog configuration file.

Step 1 – Exclude Spring Boot’s default logging

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

Step 2 – Add tinylog dependencies

<properties>
    <tinylog.version>2.4.1</tinylog.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.tinylog</groupId>
        <artifactId>tinylog-api</artifactId>
        <version>${tinylog.version}</version>
    </dependency>
    <dependency>
        <groupId>org.tinylog</groupId>
        <artifactId>tinylog-impl</artifactId>
        <version>${tinylog.version}</version>
    </dependency>
    <dependency>
        <groupId>org.tinylog</groupId>
        <artifactId>slf4j-tinylog</artifactId>
        <version>${tinylog.version}</version>
    </dependency>
    <dependency>
        <groupId>org.tinylog</groupId>
        <artifactId>jcl-tinylog</artifactId>
        <version>${tinylog.version}</version>
    </dependency>
    <dependency>
        <groupId>org.tinylog</groupId>
        <artifactId>log4j1.2-api</artifactId>
        <version>${tinylog.version}</version>
    </dependency>
</dependencies>

Step 3 – Verify the integration

Using Lombok’s @Slf4j, create a simple Spring Boot application that logs messages at all levels:

@Slf4j
@SpringBootApplication
public class Chapter83Application {

    public static void main(String[] args) {
        SpringApplication.run(Chapter83Application.class, args);
        log.error("Hello World");
        log.warn("Hello World");
        log.info("Hello World");
        log.debug("Hello World");
        log.trace("Hello World");
    }
}

Running the program prints the messages to the console, confirming that TinylogLogger is active.

Console output
Console output

Step 4 – Add tinylog configuration

Create tinylog.properties under src/main/resources with the desired format:

writer=console
writer.format={date: HH:mm:ss.SSS} {level}: {message}

After restarting, the console output follows the specified pattern. Further configuration such as file output or level control can be found in the official documentation.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaConfigurationSpring Boot
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

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.