Nuun IO Log Plugin

Nuun Log Plugin will manage the injection of SL4J Logger.

License

License

GroupId

GroupId

io.nuun
ArtifactId

ArtifactId

nuun-log-plugin
Last Version

Last Version

1.0.M1
Release Date

Release Date

Type

Type

jar
Description

Description

Nuun IO Log Plugin
Nuun Log Plugin will manage the injection of SL4J Logger.
Source Code Management

Source Code Management

https://github.com/nuun-io/nuun-log-plugin

Download nuun-log-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/io.nuun/nuun-log-plugin/ -->
<dependency>
    <groupId>io.nuun</groupId>
    <artifactId>nuun-log-plugin</artifactId>
    <version>1.0.M1</version>
</dependency>
// https://jarcasting.com/artifacts/io.nuun/nuun-log-plugin/
implementation 'io.nuun:nuun-log-plugin:1.0.M1'
// https://jarcasting.com/artifacts/io.nuun/nuun-log-plugin/
implementation ("io.nuun:nuun-log-plugin:1.0.M1")
'io.nuun:nuun-log-plugin:jar:1.0.M1'
<dependency org="io.nuun" name="nuun-log-plugin" rev="1.0.M1">
  <artifact name="nuun-log-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.nuun', module='nuun-log-plugin', version='1.0.M1')
)
libraryDependencies += "io.nuun" % "nuun-log-plugin" % "1.0.M1"
[io.nuun/nuun-log-plugin "1.0.M1"]

Dependencies

compile (3)

Group / Artifact Type Version
io.nuun : kernel-core jar 1.0.M1
io.nuun : kernel-specs jar 1.0.M1
org.slf4j : slf4j-api jar 1.6.6

test (6)

Group / Artifact Type Version
junit : junit jar 4.11
org.mockito : mockito-core jar 1.8.5
org.easytesting : fest-assert jar 1.4
ch.qos.logback : logback-classic jar 1.0.0
org.powermock : powermock-core jar 1.5
org.powermock : powermock-api-mockito jar 1.5

Project Modules

There are no modules declared in this project.

Nuun-log-plugin Build statusMaven Central

This Nuun plugin provides an easy way to inject SLF4J loggers, or to create your own logger annotation.

How to use it

Add the dependency to your pom.xml:

<dependency>
    <groupId>io.nuun</groupId>
    <artifactId>nuun-log-plugin</artifactId>
    <version>1.0.M2-SNAPSHOT</version>
</dependency>

Then, directly use it in your project.

public class MyClass {

    @NuunLog
    private Logger logger;

    ...
}

How to create my own logger annotation

Our if you are building a framework and you don't want your user to directly dependend on Nuun API, you can create your own logger annotation as follows:

@Scope
@Documented
@Retention(RUNTIME)
@Target({FIELD})
@NuunLog
public @interface AnnoCustomLog {
}

This annotation can now be used in the same way as the NuunLog annotation.

public class MyClass {

    @AnnoCustomLog
    private Logger logger;

    ...
}

Frequent questions

Should Logger members of a class be declared as static?

There is no global response. SLF4J doesn't recommand any of the solution.

We used to recommend that loggers members be declared as instance variables instead of static. After further analysis, we no longer recommend one approach over the other.

If you want more detail about when use static field or instance field see the SLF4J documentation on the subject.

Here is the pros and cons of using instance over static field (Taken from the above page).

Advantages for declaring loggers as instance variables

Possible to take advantage of repository selectors even for libraries shared between applications. However, repository selectors only work if the underlying logging system is logback-classic. Repository selectors do not work for the SLF4J+log4j combination. IOC-friendly

Disadvantages for declaring loggers as instance variables

Less common idiom than declaring loggers as static variables higher CPU overhead: loggers are retrieved and assigned for each instance of the hosting class higher memory overhead: logger declaration will consume one reference per instance of the hosting class

io.nuun

Nuun IO

Nuun.IO is a set of libraries allowing a full use of the IOC principle.

Versions

Version
1.0.M1