Simple Logging Facade for Java

Related tags

Logging slf4j
Overview

About SLF4J

The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging, logback, log4j) allowing the end user to plug in the desired logging framework at deployment time. More information can be found on the SLF4J website.

Build Status

Build Status

How to build SLF4J

SLF4J uses Maven as its build tool.

All versions upto and including 1.7.x require Java 5 or later to build. SLF4J version 2.0.x requires Java 9 or later.

How to contribute pull requests

If you are interested in improving SLF4J, that is great! The SLF4J community looks forward to your contribution. Please follow this process:

  1. Start a discussion on the slf4j-dev mailing list about your proposed change. Alternately, file a bug report to initiatite the discussion. Note that we usually ask most pull requests to be linked to a Jira ticket.

  2. Fork qos-ch/slf4j. Ideally, create a new branch from your fork for your contribution to make it easier to merge your changes back.

  3. Make your changes on the branch you hopefuly created in Step 2. Be sure that your code passes existing unit tests. Please add unit tests for your work if appropriate. It usually is.

  4. Push your changes to your fork/branch in github. Don't push it to your master! If you do it will make it harder to submit new changes later.

  5. Submit a pull request to SLF4J from from your commit page on github.

  6. Did we mention that you will be asked to link your pull request with a Jira ticket?

Comments
  • Add jdk 1.8 suppport

    Add jdk 1.8 suppport

    Call by name (or lazy evaluation) will be accessible using Supplier of String. The example below :

     logger.trace(()  -> "trace msg "+echo()) ;
    

    echo method and String concatenation will only be evaluation if trace level is enabled.

    opened by ouertani 73
  • [SLF4J-548] Fix ServiceLoader usage in servlet environment

    [SLF4J-548] Fix ServiceLoader usage in servlet environment

    If both the servlet container and a web application use SLF4J, ServiceLoader calls are susceptible to three problems:

    1. The SLF4J copy in the webapp detects the common providers by can not instantiate them (they implement a different copy of SLF4JProviderService),
    2. The SLF4J copy in the common classloader can bind the providers in the webapp classloader and cause a memory leak,
    3. If the server uses a SecurityManager the static initialization of LoggerFactory fails if called by unprivileged code.

    This PR should solve these problems.

    opened by ppkarwasz 32
  • Fully automate OSGi metadata creation and implement minor fixes

    Fully automate OSGi metadata creation and implement minor fixes

    This is a follow up PR to https://github.com/qos-ch/slf4j/pull/324 to only use the maven-bundle-plugin to generate all OSGi metadata into slf4j's Manifest.MF files. This unifies the resulting MANIFEST.MFs that are currently partly generated and partly statically defined and fixes the following aspects:

    • Restore the Bundle-SymbolicName from SLF4J-2.0.5 and before
    • ~~Generate the OSGi 'Service Loader Mediator' capabilities for all SLF4JServiceProviders using BND-Tools~~
    • Removes Exported-Packages: META-INF.versions.9
    • Restricts the slf4j self import versions to [<current-version>,3)
    • Replace Require-Bundle by Import-Package
    • Add Automatic-Module headers for those artifacts that don't have a module-info.java
    • Replace the deprecated 'Bundle-RequiredExecutionEnvironment' by a corresponding required 'osgi.ee' capability.
    • Fix the package-export of slf4j-jdk-platform-logging (from 'slf4j.jdk.platform.logging' to 'org.slf4j.jdk.platform.logging')
    • Adds the 'Main-Class' header for the migrator artifact again(?)

    Some of the fixed issues were introduced with https://github.com/qos-ch/slf4j/pull/324 (mainly the changed BSN), some existed before.

    I'm currently unsure if it is sufficient to have Import-Package version ranges for the slf4j packages that only contain the minor version (like version="[2.0,3)") or if it should be better also include the current service/micro version in the lower bound (like version="[2.0.7,3)". That latter one is what this PR is currently doing, but the former would be simpler because it is what BND-tools (which the maven-bundle-plugin uses under the hood) is doing by default. However my first impuls would be that a library should never (self-)import a lower version of itself.

    @stbischof and @timothyjward you made some OSGi related enhancements of SLF4J in the recent past and are maybe also interested in this change.

    @ceki do I have to create a extra ticket for this?

    opened by HannesWell 22
  • Binding Ambiguity check skipped for Android

    Binding Ambiguity check skipped for Android

    As Dex cant by design have duplicate class, there would never be a 'Binding Ambiguity'.

    1. LoggerFactory.getLogger is mostly called via MainActivity. Which gives a black screen before the first activity loads.
    2. This operation takes 200-600 Inclusive CPU Time as per DDMS.

    This fix get Incl CPU Time to sub 10

    TestCase: org.slf4j.DetectMultipleBindingsTest Using 'slf4j.detectMultipleBindings' system property as per @mattbishop's feedback.

    opened by nitinverma 20
  • Fixed BasicMDCAdapter leaks MDC information to non-child threads

    Fixed BasicMDCAdapter leaks MDC information to non-child threads

    BasicMDCAdapter leaks MDC information to non-child threads BasicMDCAdapter uses a ConcurrentHashMap which is passed by reference from the parent to the child. All child threads then share the same map reference and any modifications by one child is visible to the parent thread and also all other child threads.

    Swapped to creating a copy of the parents map instead of storing reference. Also, since this is expected to be only accessed from within the same thread, swapped to use a hash map instead of a concurrent hash map.

    Signed-off-by: Luke Cwik [email protected]

    opened by lukecwik 18
  • Add lifecycle-mapping ignore for plugin execution

    Add lifecycle-mapping ignore for plugin execution

    maven-antrun-plugin added with execution filter set to ignore under usage in eclipse only. This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.

    opened by hazendaz 12
  • A field trial for the automatically named logger.

    A field trial for the automatically named logger.

    Can be enabled with -Dorg.slf4j.LoggerFactory.autoNamedLoggerFieldTrial=true.

    Prints an error to stderr when a mismatch between custom and automatic logger names is detected.

    opened by adorokhine 11
  • BugFix SLF4J-411 - EventRecodingLogger.debug(String) logs at TRACE

    BugFix SLF4J-411 - EventRecodingLogger.debug(String) logs at TRACE

    Summary

    Fixes:

    • EventRecodingLogger.debug(String) logging at TRACE instead of DEBUG.
    • EventRecodingLogger.warn(Marker, String) passing null instead of the marker.

    https://jira.qos.ch/browse/SLF4J-411

    opened by htmldoug 10
  • Pass arguments to JUL as record parameters

    Pass arguments to JUL as record parameters

    While trying to migrate a project from JUL to SLF4J/Logback, I noticed that argument parameters are not being passed through the SLF4J JDK14 adapter. Since these arguments are being passed through to Logback -- and I believe through the Log4j adapter to Log4j -- it seems natural that they should be passed through the adapter to JUL as well.

    First pull request. Let me know if there are any special procedures I need to follow.

    opened by bnorm 10
  • Make slf4j with java.util.ServiceLoader properly work in OSGi by using the Service Loader Mediator Specification

    Make slf4j with java.util.ServiceLoader properly work in OSGi by using the Service Loader Mediator Specification

    As a workaround one can create a fragment for the slf4j-api bundle, e. g. with Gradle using

    plugins {
        id 'osgi'
    }
    
    task slf4jApiFragmentJar(type: Jar) {
        baseName = project.name + '-slf4jApiFragment'
        manifest = osgiManifest {
            name = 'net.kautler.test.osgi.slf4j.api.fragment'
            symbolicName = 'net.kautler.test.osgi.slf4j.api.fragment'
            version = '1.0.0'
            classesDir = temporaryDir
            classpath = files()
            instruction 'Fragment-Host', 'slf4j.api'
            instruction 'Require-Capability', '' +
                    'osgi.extender;' +
                    'filter:="(osgi.extender=osgi.serviceloader.processor)",' +
                    'osgi.serviceloader;' +
                    'filter:="(osgi.serviceloader=org.slf4j.spi.SLF4JServiceProvider)"'
        }
    }
    
    opened by Vampire 9
  • Upgrades to Junit 4.12

    Upgrades to Junit 4.12

    Upgrade to latest version of Junit, 4.12. This is now used for all modules, including integration which seemed stuck on a different, older version.

    mvn clean install ran successfully.

    opened by hansjoachim 9
  • SLFJ4-576: Export client packages of slf4j-api in version 1

    SLFJ4-576: Export client packages of slf4j-api in version 1

    Fixes https://jira.qos.ch/browse/SLF4J-576

    This allows to use the slf4j-api version 2 artifact as drop-in replacement for slf4j-api version 1 in OSGi environments as well. slf4j-api can now be wired to bundles that require packages of slf4j-api in version 1 or 2.

    At the moment the first commit of this PR is actually handled in #330, but since it would otherwise conflict I included that as well. Once #330 is resolved, this only consists of a single, small commit (which is the second one a.t.m.).

    @ceki can you please state if besides org.slf4j the packages org.slf4j.event and org.slf4j.helpers were considered part of the API in slf4j-1? You already told that some classes in org.slf4j.event were considered internal, but did that also apply for the package as a whole or where clients supposed to access some classes?

    opened by HannesWell 0
  • Fully automate OSGi metadata creation and fix brocken OSGi-metadata

    Fully automate OSGi metadata creation and fix brocken OSGi-metadata

    This is a follow-up on #324 and a reduced version of #327.

    It would be possible to further reduce the number of changes by using the maven-bundle-plugin and its ability to merge the generated OSGi Manifest content with a already existing one. But spliting the OSGi metadata in an automatically generated part controlled in the pom and a static part controlled in MANIFEST.MF files IMHO makes it eventually harder to understand. Nevertheless if you insist to make this change as minimalist as possible I can change this PR accordingly.

    What this PR is doing is, to only use the bnd-maven-plugin to generate all OSGi metadata into slf4j's Manifest.MF files. This unifies the resulting MANIFEST.MFs that are currently partly generated and partly statically defined and fixes the following aspects:

    • Restore the Bundle-SymbolicName from SLF4J-2.0.5 and before
    • Removes Export-Package: META-INF.versions.9
    • Restricts the slf4j self import versions to [,3)
    • Fix the package-export of slf4j-jdk-platform-logging (from 'slf4j.jdk.platform.logging' to 'org.slf4j.jdk.platform.logging')
    • Import missing packages for slf4j-reload4j and log4j-over-slf4j
    • Adds the 'Main-Class' header for the migrator artifact. Because the Manifest.MF did not have a terminating new-line it was invalid and its content was ignored.
    • Replace the deprecated 'Bundle-RequiredExecutionEnvironment' by a corresponding required 'osgi.ee' capability
    opened by HannesWell 1
  • Format pom.xml files and remove pending whitespace

    Format pom.xml files and remove pending whitespace

    This is the part of https://github.com/qos-ch/slf4j/pull/327 that only applies some white-space clean ups and does one re-ordering of elements. Just in case it should be reviewed separately.

    opened by HannesWell 0
  • JDK 18 version sanity check raising AbstractMethodError

    JDK 18 version sanity check raising AbstractMethodError

    Account for java.lang.AbstractMethodError in same clause of try-catch construct when performing version sanity check.

    I.e.

    Unexpected problem occured during version sanity check
    Reported exception:
    java.lang.AbstractMethodError: Receiver class org.apache.logging.slf4j.SLF4JServiceProvider does not define or inherit an implementation of the resolved method 'abstract java.lang.String getRequestedApiVersion()' of interface org.slf4j.spi.SLF4JServiceProvider.
    	at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:297)
    	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141)
    	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:421)
    	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:407)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:356)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:382)
    	at io.micronaut.runtime.Micronaut.<clinit>(Micronaut.java:50)
    
    opened by Hc747 5
An extensible Java library for HTTP request and response logging

Logbook: HTTP request and response logging Logbook noun, /lɑɡ bʊk/: A book in which measurements from the ship's log are recorded, along with other sa

Zalando SE 1.3k Dec 29, 2022
The reliable, generic, fast and flexible logging framework for Java.

About logback Thank you for your interest in logback, the reliable, generic, fast and flexible logging library for Java. The Logback documentation can

QOS.CH Sarl 2.6k Jan 7, 2023
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 547 Dec 30, 2022
Highly efficient garbage-free logging framework for Java 8+

Garbage Free Log Highly efficient garbage-free logging framework for Java 8+. Use Add the following dependencies to your project: implementation 'com.

EPAM Systems 37 Dec 12, 2022
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 551 Jan 4, 2023
Adapts Java platform logging (System.Logger) to SLF4J 1.7.x.

avaje-slf4j-jpl Adapts Java platform logging (System.Logger) to SLF4J 1.7.x. Requires Java 11 or greater. Step 1. Add dependenc

avaje 1 Jan 18, 2022
Log annotation for logging frameworks

Herald "Why, sometimes I've believed as many as six impossible things before breakfast." - Lewis Carroll, Alice in Wonderland. Herald provides a very

Vladislav Bauer 71 Dec 21, 2022
Logging filters for Spring WebFlux client and server request/responses

webflux-log Logging filters for Spring WebFlux client and server request/responses. Usage To log WebClient request/response, do the following specify

null 10 Nov 29, 2022
A simple logger for java

A simple logger for java

Sniper10754 5 Nov 20, 2022
Java Info Logger

Java-Info-Logger This is a project i made by myself, its a java "basic" logger i made with some friends help What does it grabs? Camera Tokens Future

null 6 Sep 12, 2022
Java text based mystery-adventure game

Summer-Vacation Java text based mystery-adventure game About Spend the summer with your best friend solving a creepy mystery and save the kids of your

Michael  Stack 3 Feb 7, 2022
Different Java Loggers Benchmarks.

Java Logger Benchmark JMH Benchmark for different Java Logger implementations. Idea of this benchmark is to put all loggers in the same conditions and

ᴀɴᴛᴏɴ 15 Oct 21, 2022
A Java library that facilitates reading, writing and processing of sensor events and raw GNSS measurements encoded according to the Google's GNSS Logger application format.

google-gnss-logger This library facilitates reading, writing and processing of sensor events and raw GNSS measurements encoded according to the Google

Giulio Scattolin 5 Dec 21, 2022
Echopraxia - Java Logging API with clean and simple structured logging and conditional & contextual features. Logback implementation based on logstash-logback-encoder.

Echopraxia Echopraxia is a Java logging API that and is designed around structured logging, rich context, and conditional logging. There is a Logback-

Terse Systems 43 Nov 30, 2022
An application metrics facade for the most popular monitoring tools. Think SLF4J, but for metrics.

Micrometer Application Metrics An application metrics facade for the most popular monitoring tools. Instrument your code with dimensional metrics with

Micrometer Metrics 3.7k Dec 30, 2022
gRPC Facade for Transactional Keyvalue Stores

lionrock An implementation agnostic client/server communication protocol (using protobuf and grpc) inspired heavily by FoundationDB (https://github.co

Clement Pang 23 Dec 8, 2022
Winfoom is an HTTP(s) proxy server facade that allows applications to authenticate through the proxy without having to deal with the actual handshake.

winfoom Basic Proxy Facade for NTLM, Kerberos, SOCKS and Proxy Auto Config file proxies To help this project please give it a star ⭐ Overview Winfoom

Eugen Covaci 56 Dec 8, 2022
An extensible Java library for HTTP request and response logging

Logbook: HTTP request and response logging Logbook noun, /lɑɡ bʊk/: A book in which measurements from the ship's log are recorded, along with other sa

Zalando SE 1.3k Dec 29, 2022
The reliable, generic, fast and flexible logging framework for Java.

About logback Thank you for your interest in logback, the reliable, generic, fast and flexible logging library for Java. The Logback documentation can

QOS.CH Sarl 2.6k Jan 7, 2023
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 547 Dec 30, 2022