Home > Java > javaTutorial > body text

Java Spring Boot use Seq for logging

Barbara Streisand
Release: 2024-10-22 06:08:03
Original
351 people have browsed it

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

Java Spring Boot use Seq for logging

Add these to build.gradle for dependency

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

dependencies {
    ...
    implementation 'com.github.serilogj:serilogj:v0.6.1'
}
Copy after login

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");
Copy after login

With this setup the logger should work

Java Spring Boot use Seq for logging

You can find the code here

Reference

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

The above is the detailed content of Java Spring Boot use Seq for logging. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!