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

Logger.getLogger (compact initialization)

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 2.0.0-alpha1
    • Core API
    • None
    • Manual definition of Logger field in class.

       

    Description

      Most common use case of logger declaration looks like

      
      import org.slf4j.Logger;
      
      import org.slf4j.LoggerFactory;
      
      ...
      
      private static final Logger logger = LoggerFactory.getLogger(CurrentType.class);
      
      

       

      It's almost fine, but it could be more compact:

      
      import org.slf4j.Logger;
      
       ...
      
      private static final Logger logger = Logger.getLogger(CurrentType.class);
      
      

       

      Before java 8 it was not possible (Logger is an interface, not abstract class), now since the minimum required version is 9, the static initialization method can be introduced in the interface.

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            seregamorph Sergey Chernov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: