flogger-parent

Flogger Parent

License

License

GroupId

GroupId

com.jahnelgroup.flogger
ArtifactId

ArtifactId

flogger-parent
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

flogger-parent
Flogger Parent
Project URL

Project URL

https://github.com/JahnelGroup/flogger
Source Code Management

Source Code Management

https://github.com/JahnelGroup/flogger/tree/master

Download flogger-parent

Filename Size
flogger-parent-2.0.0.pom 7 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/com.jahnelgroup.flogger/flogger-parent/ -->
<dependency>
    <groupId>com.jahnelgroup.flogger</groupId>
    <artifactId>flogger-parent</artifactId>
    <version>2.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.jahnelgroup.flogger/flogger-parent/
implementation 'com.jahnelgroup.flogger:flogger-parent:2.0.0'
// https://jarcasting.com/artifacts/com.jahnelgroup.flogger/flogger-parent/
implementation ("com.jahnelgroup.flogger:flogger-parent:2.0.0")
'com.jahnelgroup.flogger:flogger-parent:pom:2.0.0'
<dependency org="com.jahnelgroup.flogger" name="flogger-parent" rev="2.0.0">
  <artifact name="flogger-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.jahnelgroup.flogger', module='flogger-parent', version='2.0.0')
)
libraryDependencies += "com.jahnelgroup.flogger" % "flogger-parent" % "2.0.0"
[com.jahnelgroup.flogger/flogger-parent "2.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.aspectj : aspectjweaver jar 1.8.13
org.slf4j : slf4j-api jar 1.7.25

runtime (1)

Group / Artifact Type Version
org.aspectj : aspectjrt jar 1.8.13

Project Modules

  • flogger-core
  • flogger-spring-boot

Flogger

Build Status

Whip your logs into shape!

Flogger is an AspectJ library that provides the ability to easily add information to the MDC.

Table of Contents

Install

Spring Boot

Adding Flogger to a Spring Boot project is as simple as adding a dependency to flogger-spring-boot.

<dependency>
    <groupId>com.jahnelgroup.flogger</groupId>
    <artifactId>flogger-spring-boot</artifactId>
    <version>2.0.0</version>
</dependency>

Java 8

Flogger can also be used in plain Java projects using the aspectj-maven-plugin.

flogger-sample is an example project showing how to set it up.

Usage

To add method parameters to the MDC, annotate them with @BindParam.

To add the return value of a method to the MDC, annotate the method with @BindReturn.

The key in the MDC can be customized by the value field on both annotations.

Expansion

You can expand an object before it gets added to the MDC by setting expand=true in the annotations.

This will add the object's field values and method return values (only methods that take 0 parameters) to the MDC instead of calling .toString() on the object.

By default, every field and method on the object will be added to the MDC. This can be customized similar to Lombok's @EqualsAndHashCode.

To exclude a field/method, annotate it with @BindExpand.Exclude.

You can specify exactly which fields/methods are to be added to the MDC by annotating the object's class with @BindExpand(onlyExplicityIncluded=true) and then each method/field you wish to add with @BindExpand.Include.

The key in the MDC for expanded fields/methods can be customized by the value field on @BindExpand.Include.

Example

public class Expanded {
    
    private String field = "field"

    private String method() {
        return "method";    
    }
    
    public String toString() {
        return "expanded.toString()";
    }
}

...

public void method(@BindParam(expand=?) Expanded expanded) {...}

When expand=false the MDC contains :

{expanded=expanded.toString()}

When expand=true the MDC contains:

{field=field, method=method, toString=expanded.toString()}

License

MIT © Jahnel Group

com.jahnelgroup.flogger

Jahnel Group

Versions

Version
2.0.0
1.4.0
1.3.0