Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 51715 invoked from network); 20 Jan 2009 23:16:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jan 2009 23:16:07 -0000 Received: (qmail 51934 invoked by uid 500); 20 Jan 2009 23:16:04 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 51914 invoked by uid 500); 20 Jan 2009 23:16:04 -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 51903 invoked by uid 99); 20 Jan 2009 23:16:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 15:16:04 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jmedina@e-dialog.com designates 64.28.75.202 as permitted sender) Received: from [64.28.75.202] (HELO corp-mail.e-dialog.com) (64.28.75.202) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 20 Jan 2009 23:15:56 +0000 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: Orthogonal logging configuration Date: Tue, 20 Jan 2009 18:15:34 -0500 Message-ID: <9DD36C99332AB7438F8D73C048D8C62C01D9302D@sneezy.ad.e-dialog.com> In-Reply-To: <9DD36C99332AB7438F8D73C048D8C62C01D93026@sneezy.ad.e-dialog.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Orthogonal logging configuration Thread-Index: Acl7U8tdNn3/hu/pTYyyU5UnBOU8GQAAQFGA References: <9DD36C99332AB7438F8D73C048D8C62C01D93026@sneezy.ad.e-dialog.com> From: "Jorge Medina" To: "Log4J Users List" X-Virus-Checked: Checked by ClamAV on apache.org For Option (2) I just realized I would have override LogManager, since all calls to get a Logger from the Logger class calls methods on LogManager.=20 Any other ideas are welcome. Thank you. -Jorge -----Original Message----- From: Jorge Medina [mailto:jmedina@e-dialog.com]=20 Sent: Tuesday, January 20, 2009 6:07 PM To: log4j-user@logging.apache.org Subject: Orthogonal logging configuration Hi, I have a web services application that can be used by a few clients (each client may have several users, but this is not relevant. By client I mean a customer organization, not a client of a client-server system) =20 a) I would like to have separate log files, one per each client. Of course, there may be sections of code that are executed before I know what client is making the request, the log statements on those sections of code would go to the global file.=20 =20 b) I would also like to be able to change the log level per package per client. For example, I want to log at DEBUG level for all requests coming from client X but only at INFO level for client Y for a given package "com.example.mypackage".=20 =20 In other words, package and client would be my orthogonal axis. =20 =20 I was wondering if someone may already have this problem and have a solution. =20 Here is what I have been thinking on doing: =20 Option 1) Change all Logger.getLogger("x.y.z") for Logger.getLogger("clientID.x.y.z") in my code. Advantages: Easy to achieve (a) and (b) Disadvantages: It would only work for my own code, but not for logging produced by third party libraries. (Vgr. Spring, Hibernate, etc). I would really like to log all relevant information into the same log file for a given client. When a request is made, as soon as I know the client, I want all logging of that transaction (my own code, spring, hibernate, other libraries) to go to the appropiate appender. =20 Option 2) Write my own Logger class, overriding the the Log4j class. The Logger.getLogger("x") method will return the logger "clientID.x" if an InheritableThreadLocal variable is available with the clientID, otherwise it returns logger "x". Advantages:=20 It will work for my own code and third party code. Disadvantages: Little more complex to implement. =20 =20 I was wondering if anybody have had a similar requirement. Any ideas are welcome. =20 -Jorge --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org