Skip to content

nanolaba/nanolog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

[ en | ru ]

Nanolaba logger (Nanolog)

Nanolog — is a simple but powerful logger for Java applications, compatible with SLF4J, that removes the need for static logger instances in every class requiring logging.

Overview

Nanolog provides an advanced API for application logging, offering additional features not found in other popular logger implementations:

  1. Automatic caller class detection
  2. Lazy message initialization via Supplier
  3. Parameterized message support
  4. Safe object-to-string conversion
  5. Easy creation of custom logger implementations

Nanolog is an extremely lightweight library and can be used as a standalone logger. However, it also supports integration with SLF4J, enabling compatibility with other logging libraries that act as its bridges — such as Logback, Log4j, JBoss Logging, and others.

Nanolog compatible with Java 8+.

The latest stable version of the library is 1.0.

The latest development version is 1.1-SNAPSHOT.

Table of contents

  1. Quick Start
  2. Usage Guide
    1. Adding the library to the project
    2. Using SNAPSHOT versions
    3. Setting up the logger type
      1. ConsoleLogger
      2. Slf4jLogger
      3. Creating a custom logger implementation
  3. Feedback

Quick Start

package com.nanolaba.logging.examples;

import com.nanolaba.logging.*;

public class QuickStart {
    public static void main(String[] args) {
        try {
            // This is the logger used by default
            LOG.init(new ConsoleLogger());

            // If you want to use SLF4J
            LOG.init(new Slf4jLogger());

            // If you want to write your own logger, use a lambda function 
            // or implement the ILogger interface.
            LOG.init(entry -> System.err.println(entry.getLevel() + " - " +
                    entry.getSourceClass() + " - " +
                    entry.getFormattedMessage()));

            LOG.debug("A static logger variable is not needed");
            LOG.info(String.class, "But you can explicitly specify which class the logging should belong to");
            LOG.warn("This is a parameterized message: {}, {}, {} ",
                    100, "foo", new Object[]{"foo", "bar"});

            if (LOG.isDebugEnabled()) {
                LOG.debug("You can check if a log level is enabled in the standard way: " +
                        hugeComputations());
            }
            LOG.debug(() -> "It's also possible to pass a lambda expression: " +
                    hugeComputations());

        } catch (Exception e) {
            LOG.error(e);
        }
    }

    private static String hugeComputations() {
        return "OK";
    }
}

Usage Guide

Adding the library to the project

Maven (pom.xml)

<dependency>
    <groupId>com.nanolaba</groupId>
    <artifactId>nanolog</artifactId>
    <version>1.0</version>
</dependency>  

Gradle (build.gradle)

dependencies {
    implementation 'com.nanolaba:nanolog:1.0'
}

Manual download

Get the JAR from Maven Central. Add it to your project's classpath

Using SNAPSHOT versions

To use the latest development version in your project, you need to specify the snapshot
repository URL and then add a dependency with the -SNAPSHOT suffix:

Maven (pom.xml)

<repositories>
    <repository>
        <id>central.sonatype.com-snapshot</id>
        <url>https://central.sonatype.com/repository/maven-snapshots</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
        </snapshots>
    </repository>
</repositories>

<dependency>
    <groupId>com.nanolaba</groupId>
    <artifactId>nanolog</artifactId>
    <version>1.1-SNAPSHOT</version>
</dependency>  

Gradle (build.gradle)

repositories {
    maven {
        url 'https://oss.sonatype.org/content/repositories/snapshots'
    }
}

dependencies {
    implementation 'com.nanolaba:nanolog:1.1-SNAPSHOT'
}

Setting up the logger type

📌 ⌛ Not done yet...

ConsoleLogger

📌 ⌛ Not done yet...

Slf4jLogger

📌 ⌛ Not done yet...

Creating a custom logger implementation

📌 ⌛ Not done yet...

Feedback

📌 ⌛ Not done yet...

Last updated: 07.07.2025

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages