DEV Community

Cover image for Java Spring Boot use Seq for logging
Minhaz
Minhaz

Posted on

1

Java Spring Boot use Seq for logging

The primary motivation is that I use SEQ for logging, but I couldn't find a quick complete guide to use SEQ with java spring boot using gradle. So here I'm documenting my findings.

Steps

I'm using this configuration for the project

Project setup

Add these to build.gradle for dependency

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

dependencies {
    ...
    implementation 'com.github.serilogj:serilogj:v0.6.1'
}
Enter fullscreen mode Exit fullscreen mode

Now just configure the logger

// import serilogj.Log;
// import serilogj.LoggerConfiguration;
// import serilogj.events.LogEventLevel;
// import static serilogj.sinks.seq.SeqSinkConfigurator.seq;

// setting up the logger
Log.setLogger(new LoggerConfiguration()
        .writeTo(seq("http://localhost:5341/"))
        .setMinimumLevel(LogEventLevel.Verbose)
        .createLogger());

// using the logger
var logger = Log.getLogger().forContext(SpringApplication.class);
logger.information("Hello World");
Enter fullscreen mode Exit fullscreen mode

With this setup the logger should work

SEQ Working

You can find the code here

Reference

  1. https://docs.datalust.co/docs/using-java
  2. My blog
  3. Source Code

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs