Class Slf4jCollector

java.lang.Object
sirius.stellar.logging.collect.slf4j.Slf4jCollector
All Implemented Interfaces:
AutoCloseable, sirius.stellar.logging.spi.LoggerCollector, sirius.stellar.logging.spi.LoggerExtension

public final class Slf4jCollector extends Object implements sirius.stellar.logging.spi.LoggerCollector

Implementation of LoggerCollector that delegates to SLF4J.

This is available for users to make use of stellar.logging as an API, passing logging messages to their desired underlying implementation in order to retrofit applications making use of more complicated logging setups.

When using this collector, consider the following behavior:

  • the level configured for Logger is still significant
  • by default, all messages will be reported as arriving from the thread that the collector is invoked from (managed by the executor in Logger)
  • a slight delay may be experienced in timestamps, as the underlying SLF4J implementation will compute the timestamp, and the level mapping.
  • This is automatically instantiated when on the module-path/class-path, as a LoggerExtension service provider.

Ensure this collector is never on the module path if:

  • you do not want to use an SLF4J logging backend
  • you have the SLF4J dispatcher on the classpath, which itself is a logging backend that intercepts SLF4J calls - having both the dispatcher and the collector on the module path will lead to a StackOverflowError at best.

LoggerLevel org.slf4j
INFORMATION INFO
WARNING WARN
ERROR ERROR
STACKTRACE TRACE
DEBUGGING DEBUG
CONFIGURATION DEBUG

Since:
1.0
  • Constructor Details

    • Slf4jCollector

      public Slf4jCollector()
  • Method Details

    • collect

      public void collect(sirius.stellar.logging.LoggerMessage message)
      Specified by:
      collect in interface sirius.stellar.logging.spi.LoggerCollector