Logger Spring Boot Save

A Spring Boot @Loggable annotation that will help you log your application more easily

Project README

Spring Boot Logger

A Spring Boot @Loggable annotation that will help you log your application more easily.

Base on jcabi-aspects project @Loggable annotation.

Build Status Coverage Status

Maven Central Sonatype Nexus (Snapshots)

License

Features

Register the Logger to your Spring Boot application and allow it to log wherever you tell it to. The Logger uses the slf4j to support abstraction for various logging frameworks.

Setup

In order to add logger to your project simply add this dependency to your classpath:

<dependency>
    <groupId>com.github.rozidan</groupId>
    <artifactId>logger-spring-boot</artifactId>
    <version>1.1.0</version>
</dependency>
compile 'com.github.rozidan:logger-spring-boot:1.1.0'

For snapshots versions add the sonatype public repository:

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/groups/public" }
    ...
}

Log your application

Apply the Logger to your application with @EnableLogger annotation in a configuration class:

@Configuration
@EnableLogger
public class LoggerConfig {

}

Simply add the @Loggable annotation to a method, or to a class scope:

@RestController
@RequestMapping(path = "/employees")
public class EmployeeController {
	
	@Loggable
	@GetMapping
	public List<EmployeeDto> listAllEmployees() {
	}
}

More examples:

Warning whenever execution is over 2 sec:

@Loggable(warnOver = 2, warnUnit = TimeUnit.SECONDS)

This will result 2 lines of log, one where 2 sec are over, and the other when execution is complete:

.....c.i.s.l.w.c.EmployeeController           : #listAllEmployees([]): in PT2.833S and still running (max PT0.002S)
.....c.i.s.l.w.c.EmployeeController           : #listAllEmployees([]): [] in PT6.345S (max PT0.002S)

Log when enter to a method:

@Loggable(entered = true)

Skip printing arguments and results of a method:

@Loggable(skipArgs = true, skipResult = true)

Log with different level (default is INFO):

@Loggable(LogLevel.WARN)

Set a different logger name (default is class name):

@Loggable(value = LogLevel.WARN, name = "my-logger-name")

License

Apache-2.0

Open Source Agenda is not affiliated with "Logger Spring Boot" Project. README Source: rozidan/logger-spring-boot
Stars
28
Open Issues
1
Last Commit
4 years ago
License

Open Source Agenda Badge

Open Source Agenda Rating