Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1.2
    • Fix Version/s: None
    • Labels:
      None

      Description

      Presently, in Apache Commons, the most common way to get a logger is to do something like:

      public class MyClass

      { private static Log log = LogFactory.getLog(MyClass.class); }

      Notice how MyClass.class (or alternatively a string name) is passed as a parameter. The annoying aspect of this is that sometimes the class name doesn't get updated when doing copy/paste operations. A desirable alternative might be:

      public class MyClass

      { private static Log log = LogFactory.getLog(); //class name inferred from call stack }

      With such an approach there are two possible concerns I can foresee:

      • Call stack inspection isn't terribly fast. However since Loggers are generally initialized only once, when the class is first loaded, performance isn't likely to be a major problem.
      • Commons-logging is Java 1.1 compatible. Thus care must be taken to ensure compatibility isn't broken.
      • Commons-logging doesn't depend on commons-lang, and thus the utilities in commons-lang cannot be used.

      In Java 1.4, the call stack is easily obtained using Thread.getCallStack(). Prior to Java 1.4, the only way to obtain the call stack is to inspect the stack trace of an exception.

      1. LogFactory.java
        82 kB
        Doug Bateman
      2. CallStackUtil.java.0
        7 kB
        Doug Bateman
      3. CallStackUtil.java.1
        9 kB
        Doug Bateman
      4. CallStackUtil.java.2
        8 kB
        Doug Bateman
      5. CallStackTestCase.java
        3 kB
        Doug Bateman

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Doug Bateman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development