[slf4j-dev] [Bug 163] New: Copy & paste of LoggerFactory.getLogger

bugzilla-daemon at pixie.qos.ch bugzilla-daemon at pixie.qos.ch
Thu Dec 10 09:13:31 CET 2009


http://bugzilla.slf4j.org/show_bug.cgi?id=163

           Summary: Copy & paste of LoggerFactory.getLogger
           Product: SLF4J
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core API
        AssignedTo: slf4j-dev at qos.ch
        ReportedBy: thomas.tom.mueller at gmail.com


This is a feature request.

Currently, when I create a new logger in a class, I copy & paste the following
line from another class:

  private static Logger log = LoggerFactory.getLogger(AcmeImpl.class);

Sometimes I forget to change the class name. SLF4J could help me here. I
suggest to add a new method, so the class name is not required, so that I can
copy & paste the line without having to remember that I have to change the
class name. Also, it's a bit shorter:

  private static Logger log = LoggerFactory.getCallerClassLogger();

This is copy & paste friendly. The implementation is tricky, but trivial once
you understand it:

  getCallerClassLogger() {
    return getLogger(new Error().getStackTrace()[1].getClassName());
  }

There is a project that tries to solve the copy & paste problem:
http://code.google.com/p/morbok/


-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the slf4j-dev mailing list