Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-384

Implement slf4j to log4j2 bridge/adapter/impl

    XMLWordPrintable

Details

    • Icon: New Feature New Feature
    • Resolution: Not a bug
    • Icon: Minor Minor
    • None
    • None
    • None
    • None

    Description

      Sorry if this is a dumb question. But I cannot find how slf4j would integrate on top of log4j2.

      I have tried using slf4j 1.7.21 with log4j 2.7 and keep running into this: Failed to instantiate SLF4J LoggerFactory Reported exception: java.lang.NoClassDefFoundError: org/apache/log4j/Level at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)

      From what I can see, LoggerFactory is bound to log4j pre 2.0 as there is no .logging. in the package names: package org.slf4j.impl; import org.apache.log4j.Level; import org.slf4j.ILoggerFactory; import org.slf4j.LoggerFactory; import org.slf4j.helpers.Util; import org.slf4j.spi.LoggerFactoryBinder; /** * The binding of

      {@link LoggerFactory}

      class with an actual instance of *

      {@link ILoggerFactory}

      is performed using information returned by this class. * * @author Ceki Gülcü */ public class StaticLoggerBinder implements LoggerFactoryBinder {

      If I want log4j2, and don't want to be locked into API, I can't use slf4j. I have to go back to commons-logging (JCL). Seems like a waste because JCL and it's class loader / config confusion is what led to creation of slf4j. I'd rather keep on using slf4j and plug into whatever is the fastest logging framework at the time. From all the stats I see today, that is log4j2.

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            bluejaguar John Tal
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: