Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 71852 invoked from network); 9 Aug 2010 04:53:06 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Aug 2010 04:53:06 -0000 Received: (qmail 15416 invoked by uid 500); 9 Aug 2010 04:53:05 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 14984 invoked by uid 500); 9 Aug 2010 04:53:05 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 14709 invoked by uid 99); 9 Aug 2010 04:53:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 04:53:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Aug 2010 04:53:01 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o794qdE1006583 for ; Mon, 9 Aug 2010 04:52:39 GMT Message-ID: <15351845.228291281329559694.JavaMail.jira@thor> Date: Mon, 9 Aug 2010 00:52:39 -0400 (EDT) From: "Doug Bateman (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (LOGGING-137) LogFactory.getLog() In-Reply-To: <5537932.225391281293538953.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LOGGING-137?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Doug Bateman updated LOGGING-137: --------------------------------- Attachment: (was: CallStackTest.java) > LogFactory.getLog() > ------------------- > > Key: LOGGING-137 > URL: https://issues.apache.org/jira/browse/LOGGING-137 > Project: Commons Logging > Issue Type: New Feature > Affects Versions: 1.1.2 > Reporter: Doug Bateman > Attachments: CallStackTest.java, CallStackUtil.java, CallStackUtil.patch, LogFactory.java > > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > 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. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.