Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 85702 invoked from network); 13 Jul 2005 00:02:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jul 2005 00:02:48 -0000 Received: (qmail 35425 invoked by uid 500); 13 Jul 2005 00:02:44 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 35401 invoked by uid 500); 13 Jul 2005 00:02:43 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 35381 invoked by uid 99); 13 Jul 2005 00:02:43 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2005 17:02:43 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [203.89.192.138] (HELO mail.app.aconex.com) (203.89.192.138) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jul 2005 17:02:40 -0700 Received: from herald.aconex.com (herald.aconex.com [192.168.0.211]) by mail.app.aconex.com (Postfix) with ESMTP id 70FD1159FB4 for ; Wed, 13 Jul 2005 10:02:37 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by herald.aconex.com (Postfix) with ESMTP id 5121564007 for ; Wed, 13 Jul 2005 10:02:37 +1000 (EST) Received: from herald.aconex.com ([127.0.0.1]) by localhost (herald [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22139-02-4 for ; Wed, 13 Jul 2005 10:02:36 +1000 (EST) Received: from [192.168.0.242] (unknown [192.168.0.242]) by herald.aconex.com (Postfix) with ESMTP id 6D0DD64002 for ; Wed, 13 Jul 2005 10:02:36 +1000 (EST) Mime-Version: 1.0 (Apple Message framework v733) In-Reply-To: References: Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <03007673-F1F2-4CB1-8981-D66CD4D922CC@aconex.com> Content-Transfer-Encoding: 7bit From: Paul Smith Subject: Re: How to use Log4J in Multiple classes? App Design? Date: Wed, 13 Jul 2005 10:02:35 +1000 To: "Log4J Users List" X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at aconex.com X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I would really suggest you follow the standard pattern and have one Logger per class ala: public class MyClass { private static final Logger LOG = Logger.getLogger(MyClass.class); .... Let each class log it's own stuff. Paul Smith On 13/07/2005, at 9:57 AM, John Hurt wrote: > Hi, > > My application is split up into multiple classes. If I had > processing in > each class that I wanted to log, what's the best way to make a > reference to > the Logger available, so that for instance they all write to the > same log > file? > > Do I create an instance of the Logger class at the beginning of the > program > flow, then pass that class to all the methods/classes that plan to do > logging? > > Do I make a wrapper singleton class that has a Logger in it and all > code > refers to the wrapper class? > > Do I use a base class (or interface or abstract class) that includes a > reference to a Logger class? > > Anyone has generic examples where Logger is used in more than 1 > class, how > to use it gracefully? Thanks. > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org