tinylog Documentation

repository·v2.8·Indexed 20 days ago

https://github.com/tinylog-org/tinylog

A lightweight, fast, and easy-to-use logging framework for Java. It features a static API, property-based configuration via tinylog.properties, and supports multiple outputs. tinylog provides bindings and bridges for SLF4J, Apache Commons Logging (JCL), JBoss Logging, java.util.logging (JUL), java.lang.System.Logger, and Apache Log4j 1.2, as well as dedicated API extensions for Kotlin and Scala.

Tokens
4.7K
Snippets
13
Records
24
Agent score
72%

What's inside tinylog

  1. Use the Apache Log4j 1.2 API bridge for tinylog 2

    v2.8

    If your application or its dependencies use the legacy Apache Log4j 1.2 API, you can redirect those log calls to tinylog 2 using log4j1.2-api.jar. This allows you to replace the legacy log4j.jar with the tinylog bridge, ensuring all log entries are processed by the tinylog 2 implementation.

    Log entries forwarded through this bridge are treated identically to native tinylog 2 log entries.

    Required JARs in classpath:
    - log4j1.2-api.jar
    - tinylog-api.jar
    - tinylog-impl.jar (or another tinylog implementation)
  2. Use the tinylog 1.3 API with tinylog 2

    v2.8

    If your project or its dependencies still use the tinylog 1.3 API, you can use tinylog1.3-api.jar to bridge those calls to tinylog 2. This allows legacy tinylog 1.3 logging calls to be forwarded to the tinylog 2 API and processed by a tinylog 2 implementation.

    To enable this compatibility, ensure the following JARs are present in your classpath:

    1. tinylog1.3-api.jar (the bridge)
    2. tinylog-api.jar (the tinylog 2 API)
    3. tinylog-impl.jar (or any other tinylog 2 implementation)

    Log entries made via the 1.3 API will be seamlessly forwarded to the tinylog 2 core and handled by your chosen implementation.

  3. Use tinylog as an SLF4J binding

    v2.8
    You can use slf4j-tinylog.jar to route all log entries sent via the SLF4J API through the tinylog engine. This allows existing applications or libraries that use SLF4J to benefit from tinylog's performance and configuration without changing their source code. Log entries are forwarded from slf4j-api.jar to tinylog-api.jar and then processed by the chosen tinylog implementation.
  4. Use tinylog with JBoss Logging

    v2.8

    You can use tinylog's logging API on any web or application server that uses JBoss Logging as its central logging engine. By including tinylog-jboss.jar in your classpath, all log entries generated via the tinylog API are forwarded to JBoss Logging, and all Mapped Diagnostic Context (MDC) values are shared between them.

    Required Dependencies

    To enable forwarding to JBoss Logging, ensure the following JARs are in your classpath:

    • tinylog-api.jar
    • tinylog-jboss.jar

    Creating Separate Web App Logs

    If you want to maintain a separate log file specifically for your Web Application in addition to the central server logs, you can also include tinylog-impl.jar. tinylog supports parallel output to multiple logging back-ends simultaneously.

  5. Use the tinylog JUL bridge to redirect java.util.logging

    v2.8

    The jul-tinylog.jar bridge allows you to redirect log entries from java.util.logging.Logger to the tinylog framework. Once activated, log entries from JUL are forwarded to tinylog-api.jar and processed by your chosen tinylog implementation just like native tinylog entries.

    To use the bridge, you must call org.tinylog.jul.JulTinylogBridge.activate() before any log entries are issued via java.util.logging.Logger.

    // Must be called before any java.util.logging.Logger calls
    org.tinylog.jul.JulTinylogBridge.activate();
  6. Use tinylog in Kotlin

    v2.8

    To use tinylog as a logging framework in a Kotlin project, you must include the following JAR files in your classpath:

    1. tinylog-api.jar: The core API.
    2. tinylog-api-kotlin.jar: The Kotlin-specific API extensions.
    3. An implementation JAR, such as tinylog-impl.jar.

    tinylog-impl.jar is the default implementation. Note that since tinylog 2, you can use multiple implementations in parallel, and there are also specific implementations available for application and web servers.

    /* Required classpath components: */
    - tinylog-api.jar
    - tinylog-api-kotlin.jar
    - tinylog-impl.jar (or another implementation)
  7. Use tinylog's JBoss Logging binding

    v2.8

    You can use jboss-tinylog.jar to redirect log entries from JBoss Logging 3 to the tinylog API. Once configured, log entries from JBoss Logging are forwarded to tinylog-api.jar and processed by your chosen tinylog implementation (e.g., tinylog-impl.jar) just like native tinylog entries.

    To use this binding, ensure the following JARs are present in your classpath:

    • jboss-logging.jar (JBoss Logging 3)
    • jboss-tinylog.jar (The binding)
    • tinylog-api.jar (The tinylog API)
    • tinylog-impl.jar (Or any other tinylog implementation)
  8. Configure classpath for SLF4J-to-tinylog binding

    v2.8

    To use the SLF4J binding with tinylog, ensure the following JARs are present in your application's classpath:

    1. slf4j-api.jar (compatible with SLF4J 1.6 and 1.7)
    2. slf4j-tinylog.jar (the binding)
    3. tinylog-api.jar
    4. tinylog-impl.jar (or another tinylog implementation)
  9. Configure classpath for tinylog-jul integration

    v2.8

    To forward tinylog logs to java.util.logging, ensure the following JARs are present in your classpath:

    • tinylog-api.jar (The logging API)
    • tinylog-jul.jar (The JUL bridge)

    If you want to maintain a separate log file specifically for your Web App in addition to the central server logs, you must also include tinylog-impl.jar. tinylog supports parallel output by allowing multiple logging back-ends to run simultaneously.

    - tinylog-api.jar
    - tinylog-jul.jar
    - tinylog-impl.jar (optional, for parallel logging)
  10. Set up tinylog as a logging framework

    v2.8

    To use tinylog in your project, you must include both the API and an implementation in your classpath.

    1. Add tinylog-api.jar to your classpath.
    2. Add a logging implementation, such as tinylog-impl.jar, to your classpath.

    tinylog-impl.jar is the default implementation. Since version 2, tinylog supports using multiple implementations in parallel, and there are also specialized implementations available for application and web servers to integrate with their native logging frameworks.

  11. Use tinylog in Scala projects

    v2.8

    To use tinylog as a logging framework in a Scala project, you must include the following JAR files in your classpath:

    1. tinylog-api.jar: The core logging API.
    2. tinylog-api-scala_2.*.jar: The Scala-specific API wrapper (ensure the version suffix matches your Scala version, e.g., _2.13).
    3. An implementation JAR, such as tinylog-impl.jar, to handle the actual logging.

    Note that tinylog-impl.jar is the default implementation. Since tinylog 2, you can use multiple implementations in parallel. There are also specialized implementations available for application and web servers.

  12. Use tinylog with java.util.logging

    v2.8
    You can use the tinylog logging API on web or application servers that use java.util.logging (JUL) as their central logging engine. By including tinylog-jul.jar in your classpath, all log entries made via the tinylog API will be forwarded to java.util.logging.