/logger-adapter

A Core Java Logger Adapter

Primary LanguageJavaApache License 2.0Apache-2.0

logger-adapter

A Core Java Logger Adapter

Status

Maven Central

Sonarcloud Status Sonarcloud Status

JDK8 or JDK9 and above

I compiled this with the Open JDK8. Previous versions at maven central are build ith JDK10. I went away from the JDK10, because most projects I know, are using JDK8 in production right know. But, if you want to use this with JDK9/10/11/... you can use it.. it is working perfect! Only if you start using the JMS, it could be helpful to add a module-info.java Add the following lines, switch inside the pom.xml to the JDK version you prefer, start a mvn clean install and be happy ;-)

module rapidpm.dependencies.core.logger {
  requires log4j;
  requires transitive java.logging;
  requires slf4j.api;
  requires org.apache.logging.log4j;
  exports org.rapidpm.dependencies.core.logger;
}

Release Notes

This Lib is working with

  • Java 08 (open/oracle/ibm/zulu/graalvm)
  • Java 09 (open/oracle/ibm/zulu)
  • Java 10 (open/oracle/zulu)
  • Java 11 (open/oracle/zulu)
  • Java 12 (open/oracle/zulu)

Why?

Every time you have to define/decide what will be your logger.. But you are writing a lib? What ever you will choose, it will be wrong.

Other projects will make other decisions.. So let them decide what is right for them.

This means for you: Write an Adapter, that will decide at runtime what is the right logger-implementation.

How to use?

To use this you can go two ways. First of all, add the dependency.

Second, choose the way you want to define a Logger.

Way One:

Define a class attribute.

LoggerService logger = Logger.getLogger(getClass());

Way Two:

You can implement an interface, that will give you a method to get the logger. The interface provides a default - implementation, so there is nothing to do for you..

MyClass implements HasLogger {}