Log4j 2
  1. Log4j 2
  2. LOG4J2-564

The name of the SLF4JLogger implementation should point to Log4j 2

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Done
    • Affects Version/s: 2.0-rc1
    • Fix Version/s: 2.0-rc2
    • Component/s: SLF4J Bridge
    • Labels:
    • Environment:

      All (tried on Ubuntu 12 x64, Windows 7 x64, Mac OS X Maverick)

      Description

      The name of org.slf4j.impl.SLF4JLogger should indicate somehow that we are dealing with Log4j 2.

      Right now the class is org.slf4j.impl.SLF4JLogger

      These are the names from other bindings:
      nop : org.slf4j.helpers.NOPLogger
      simple : org.slf4j.impl.SimpleLogger
      jdk : org.slf4j.impl.JDK14LoggerAdapter
      jcl : org.slf4j.impl.JCLLoggerAdapter
      log4j : org.slf4j.impl.Log4jLoggerAdapter
      logback : ch.qos.logback.classic.Logger

      Every one of them indicates what is the binding for, in the class name (all slf4j bindings), or as part of package name (logback).

      Use case: "hook" into the functionality of the logger under slf4j to control stuff not accessible through slf4j.

      Example:
      http://code.google.com/p/okapi/source/browse/#git%2Fapplications%2Frainbow%2Fsrc%2Fmain%2Fjava%2Fnet%2Fsf%2Fokapi%2Fapplications%2Frainbow%2Flogger

      Code to reproduce this:
      =========
      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;

      public class LogHandlerFactory {
      static public void main(String [] args)

      { Logger localLogger = LoggerFactory.getLogger(LogHandlerFactory.class); String realLogger = localLogger.getClass().getName(); System.out.printf("%-8s: %s%n", args.length > 0 ? args[0] : "???", realLogger); }

      }
      =========

      Thank you,
      Mihai

        Activity

        Hide
        Matt Sicker added a comment -

        Fixed in r1583105.

        Show
        Matt Sicker added a comment - Fixed in r1583105.
        Hide
        Matt Sicker added a comment -

        I like Log4jLogger better myself, too. I'll switch it to that if you don't think it'll be an issue.

        Show
        Matt Sicker added a comment - I like Log4jLogger better myself, too. I'll switch it to that if you don't think it'll be an issue.
        Hide
        Ralph Goers added a comment -

        Matt, we had some discussions in the past and the conclusion was to try to avoid using Log4j2 as a name. It isn't clear to me why Log4jLogger is a problem since it is in a different package than what SLF4J provides.

        Show
        Ralph Goers added a comment - Matt, we had some discussions in the past and the conclusion was to try to avoid using Log4j2 as a name. It isn't clear to me why Log4jLogger is a problem since it is in a different package than what SLF4J provides.
        Hide
        Matt Sicker added a comment -

        Fixed in r1583065.

        Show
        Matt Sicker added a comment - Fixed in r1583065.
        Hide
        Matt Sicker added a comment -

        Too bad SLF4J already took Log4jLogger.

        Might as well go with Log4j2Logger. I like the org.apache.logging.slf4j namespace as the org.apache.logging.log4j.slf4j looks more appropriate to put the log4j-to-slf4j classes (to match org.apache.logging.log4j.core).

        Show
        Matt Sicker added a comment - Too bad SLF4J already took Log4jLogger. Might as well go with Log4j2Logger. I like the org.apache.logging.slf4j namespace as the org.apache.logging.log4j.slf4j looks more appropriate to put the log4j-to-slf4j classes (to match org.apache.logging.log4j.core ).
        Hide
        Mihai Nita added a comment -

        If it is simpler to keep them all in one place, no problem.
        But then it would be nice to change the class name (to something like Log4j2Logger or Log4j2LoggerAdapter, whatever).
        Main thing is to be able to identify who is talking "from under" slf4j

        Thank you,
        Mihai

        Show
        Mihai Nita added a comment - If it is simpler to keep them all in one place, no problem. But then it would be nice to change the class name (to something like Log4j2Logger or Log4j2LoggerAdapter, whatever). Main thing is to be able to identify who is talking "from under" slf4j Thank you, Mihai
        Hide
        Ralph Goers added a comment -

        SLF4J requires that the implementation provide classes in the org.slf4j namespace (StaticLoggerBinder, StaticMarkerBinder and StaticMDCBinder). The other classes could possibly move to the org.apache.logging.slf4j (or org.apache.logging.log4j.slf4j) package if you like. Since the org.slf4j package had to exist it seemed easier to just co-locate the implementation code with the binder classes.

        Show
        Ralph Goers added a comment - SLF4J requires that the implementation provide classes in the org.slf4j namespace (StaticLoggerBinder, StaticMarkerBinder and StaticMDCBinder). The other classes could possibly move to the org.apache.logging.slf4j (or org.apache.logging.log4j.slf4j) package if you like. Since the org.slf4j package had to exist it seemed easier to just co-locate the implementation code with the binder classes.
        Hide
        Matt Sicker added a comment -

        I'm wondering why we even placed Log4j classes in the org.slf4j namespace. Doesn't make much sense other than access to hidden APIs (which is generally not cool).

        Show
        Matt Sicker added a comment - I'm wondering why we even placed Log4j classes in the org.slf4j namespace. Doesn't make much sense other than access to hidden APIs (which is generally not cool).

          People

          • Assignee:
            Matt Sicker
            Reporter:
            Mihai Nita
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development