Return-Path: Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: (qmail 67923 invoked from network); 3 Oct 2006 09:13:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Oct 2006 09:13:35 -0000 Received: (qmail 83342 invoked by uid 500); 3 Oct 2006 09:13:34 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 83318 invoked by uid 500); 3 Oct 2006 09:13:34 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 83307 invoked by uid 99); 3 Oct 2006 09:13:34 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Oct 2006 02:13:34 -0700 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= Received: from [72.21.53.35] ([72.21.53.35:46973] helo=talk.nabble.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id BD/4A-29668-3A922254 for ; Tue, 03 Oct 2006 02:13:12 -0700 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1GUgH5-0006WC-7I for log4j-dev@logging.apache.org; Tue, 03 Oct 2006 02:09:15 -0700 Message-ID: <6616626.post@talk.nabble.com> Date: Tue, 3 Oct 2006 02:09:15 -0700 (PDT) From: patrick To: log4j-dev@logging.apache.org Subject: Re: Enhanced FileAppender In-Reply-To: <3FE38194C8A3334A959B64B7D9A1E27B6E3185@plejaden.seychelles.ergo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: Patrick.Wyss@mobilesolutions.ch References: <3FE38194C8A3334A959B64B7D9A1E27B6E3185@plejaden.seychelles.ergo> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N hi heri, i like the idea a lot. however (admittedly without thinking to much about it ;-} ) i'd use "Strategy pattern" http://www.dofactory.com/Patterns/PatternStrategy.aspx and something like: FileNameBuilder { public String buildFilename( LoggingEvent event ); } maybe it would be an idea to add a method public boolean closeFileAfter( LoggingEvent event ); to make it possible to close the files with a specific log event. but that's just some quick toughts ;-} best regards patrick Bender Heri wrote: > > Hello all > > Since in user list nobody commented my suggestion for an enhancement of > the FileAppender I will repeat it here. > > Problem: > A often asked issue in user list is the problem to separate log files > dependent on different criterias, like a client-ID in a server > environment, a mandant- or task-ID in scheduler applications, etc. > Although it is possible to achieve this with the existing log4j framework > all possible solutions are quite complex or have other drawbacks (own > repository selector, working with different classloaders, subclass > concrete descendents of FileAppender). > > Solution: > The FileAppender is supplied with a property of type FileNameBuilder > (Design pattern: visitor). The user-supplied implementation of this > Interface can build a filename based on whatever criterias (i.e. MDC, > global Environment, etc.). The visitor is called each time a Fileappender > wants to append a log message. The FileAppender holds a collection of file > writers for each separate file name delivered by FileNameBuilder. > To avoid the excess of open file handles the FileAppender could watch the > logging activity to one particular file. If the file was not accessed > after let's say one hour it could be closed (this timeout could also be > configurable). Special care must be done if the property "append" of the > FileAppender is false. If the file was closed because the above timeout > had elapsed and then reopened later again, the file shouldn't be > overridden. > If the config file does not specify a FileNameBuilder a default > implementation would be used which returns always the configured filename. > This wouldn't break existing code. The existing property fileName would > remain and hold always the configured filename. > > The interface of the FileNameBuilder would be like this: > > public String buildFilename( FileAppender aFileAppender ); > > > Any comments on this? > > > Heri > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-dev-help@logging.apache.org > > > -- View this message in context: http://www.nabble.com/Enhanced-FileAppender-tf2371544.html#a6616626 Sent from the Log4j - Dev mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org