Path: csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: Question about loggers Date: Thu, 08 Mar 2012 07:22:09 -0800 Organization: albasani.net Lines: 21 Message-ID: References: <4f57de3b$0$286$14726298@news.sunsite.dk> <4f57fc25$0$290$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: news.albasani.net PDMBdUi9ezAlVcj4AYBPsKH+97N1mZCo3wUtXHoNdYeJyH4h5p3YSl76+13NaS89gJK14nE7UUY83S7lE6mYZ/ObsYNouOpN3zuE++3tUHSrOAj10eo3dWK5saDmzlgj NNTP-Posting-Date: Thu, 8 Mar 2012 15:22:11 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="N5IrIWQ8DasM0xcmK7QToojgNXDfLNvzAITY/azomKWbZ2Uxg4p0QniyIWej4pvfLCEF+3RD8vllTjl60/ABDWhQlTU665+lO2X0aj3qX4LNNMJFBwwmCNfe/aQ1Og5l"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 In-Reply-To: <4f57fc25$0$290$14726298@news.sunsite.dk> Cancel-Lock: sha1:H3fDMZlNEDm04JTn5ZmQr1SNkZs= Xref: csiph.com comp.lang.java.programmer:12766 Arne Vajhøj wrote: > I would use a static logger and not call getLogger in every ctor. > > Not due to performance, because I don't think there will be much, > but because I think it is nice to keep that type of non business > logic out of the ctor, so that when one read the ctor one can focus > on the real purpose of it. I prefer instance loggers, as a rule but not always. For one thing this allows me to determine the logger's identity via a call to 'getClass()'. Mainly, though, it's the scope of the variable. In an instance context I prefer instance or local variables. In a static context I prefer local variables, occasionally static memebers. I determine the scope of the logger variable by the scope of its use. Logging is a standard enough aspect that I don't find it offputting in the logic. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg