Skip to content
/ logl Public

A simple Java logging framework for libraries

License

Notifications You must be signed in to change notification settings

logl/logl

Repository files navigation

logl: A simple Java logging framework for libraries

Build Status License

Logl aims to provide a very simple logging API for use inside libraries and other distributable components. It does not use global singletons, XML configuration files, fancy classloader tricks, complex introspection, or anything else that can create challenges when integrating libraries into larger applications.

The API for logl is available by including the org.logl:api library (logl-api.jar).

For applications using libraries that depend on logl, there are bridges available to route logging done through logl into your favourite application logging framework. Logl also includes some very lightweight logging implementations for simple use cases.

Using logl in a library

Using logl in a library is quite straight foward: require an instance of org.logl.LoggerProvider be supplied (at instantiation) to all library objects that need to perform logging. If you wish to provide a default, which is usually a good idea, use LoggerProvider.nullProvider() (or Logger.nullLogger()). E.g.:

public class MyService {

    private final Logger logger;

    MyService() {
        this.logger = Logger.nullLogger();
    }

    MyService(LoggerProvider loggerProvider) {
        this.logger = loggerProvider.getLogger(getClass());
        this.logger.debug("Instantiated MyService");
    }
}

Using a library that supports logl

When encountering a library that supports logl, your application can provide an appropriate instance of a LoggerProvider when instantiating library objects. There are LoggerProvider instances available for all major logging frameworks as well as some simple ones provided by logl-logl.

public class MyApplication {

  public static void main(String[] args) {
    LoggerProvider logProvider = SimpleLogger.toPrintWriter(stderr);
    MyService service = new MyService(logProvider);
    // do something with the service
  }
}

See the API documentation for details, specifically SimpleLogger, UnformattedLogger, JULLoggerProvider, Log4j2LoggerProvider, and Slf4jLoggerProvider.

Links

About

A simple Java logging framework for libraries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published