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…


This content originally appeared on DEV Community and was authored by Minhaz

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'
}

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");

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


This content originally appeared on DEV Community and was authored by Minhaz


Print Share Comment Cite Upload Translate Updates
APA

Minhaz | Sciencx (2024-10-21T21:32:46+00:00) Java Spring Boot use Seq for logging. Retrieved from https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/

MLA
" » Java Spring Boot use Seq for logging." Minhaz | Sciencx - Monday October 21, 2024, https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/
HARVARD
Minhaz | Sciencx Monday October 21, 2024 » Java Spring Boot use Seq for logging., viewed ,<https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/>
VANCOUVER
Minhaz | Sciencx - » Java Spring Boot use Seq for logging. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/
CHICAGO
" » Java Spring Boot use Seq for logging." Minhaz | Sciencx - Accessed . https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/
IEEE
" » Java Spring Boot use Seq for logging." Minhaz | Sciencx [Online]. Available: https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/. [Accessed: ]
rf:citation
» Java Spring Boot use Seq for logging | Minhaz | Sciencx | https://www.scien.cx/2024/10/21/java-spring-boot-use-seq-for-logging/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.