Semantic Logging (Java Version)

A Library to add semantic logging to your JVM project using SLF4J.

License

License

Categories

Categories

Ant Build Tools
GroupId

GroupId

de.roamingthings
ArtifactId

ArtifactId

semanticlogger
Last Version

Last Version

0.9.3
Release Date

Release Date

Type

Type

jar
Description

Description

Semantic Logging (Java Version)
A Library to add semantic logging to your JVM project using SLF4J.
Project URL

Project URL

https://github.com/roamingthings/semanticlogger
Source Code Management

Source Code Management

https://github.com/roamingthings/semanticlogger

Download semanticlogger

How to add to project

<!-- https://jarcasting.com/artifacts/de.roamingthings/semanticlogger/ -->
<dependency>
    <groupId>de.roamingthings</groupId>
    <artifactId>semanticlogger</artifactId>
    <version>0.9.3</version>
</dependency>
// https://jarcasting.com/artifacts/de.roamingthings/semanticlogger/
implementation 'de.roamingthings:semanticlogger:0.9.3'
// https://jarcasting.com/artifacts/de.roamingthings/semanticlogger/
implementation ("de.roamingthings:semanticlogger:0.9.3")
'de.roamingthings:semanticlogger:jar:0.9.3'
<dependency org="de.roamingthings" name="semanticlogger" rev="0.9.3">
  <artifact name="semanticlogger" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.roamingthings', module='semanticlogger', version='0.9.3')
)
libraryDependencies += "de.roamingthings" % "semanticlogger" % "0.9.3"
[de.roamingthings/semanticlogger "0.9.3"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.29

Project Modules

There are no modules declared in this project.

Semantic Logger

Build Status Java: Maven Central (Java) Kotlin: Maven Central (Kotlin)

This little library is inspired by the talk Observability in einer Microservice Welt held on Berlin Expert Days 2018 by Andreas Weigel and Jakob Fels.

If you prefer to have some semantic to your logging and improve code readability you can use the SemanticLogger and its SemanticLoggerFactory which adds a thin layer around Slf4j.

The SemanticLoggerFactory can be used like the Slf4j LoggerFactory to create a new Logger by class, name or a delegateLogger:

SemanticLogger logger = SemanticLogger. getLogger(SomeClass.class);

SemanticLogger logger = SemanticLogger. getLogger("SomeLoggerName");

Logger delegateLogger = org.slf4j.LoggerFactory.getLogger(SomeClass.class);
SemanticLogger logger = SemanticLogger. getLogger(delegateLogger);

The SemanticLogger itself provides the following methods for logging:

SemanticLogger log = SemanticLoggerFactory.getLogger(MyClass.class);
log.forTestPurpose(...);                // will log a debug event
log.asExpectedByDefault(...);           // will log an info event
log.toInvestigateTomorrow(...);         // will log a warn event
log.wakeMeUpInTheMiddleOfTheNight(...); // will log an error event

Publishing

Export the secret keys to a keyring:

gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg
 ./gradlew --console=plain -PrepositoryUser=<user> -PrepositoryPassword="<password>" -PsigningKeyId=0x12345678 -PsigningPassword="<key_password>" -PsigningSecretKeyRingFile="/path/to/secring.gpg"

Versions

Version
0.9.3
0.9.1