Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 97164 invoked from network); 18 Jan 2011 20:18:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Jan 2011 20:18:27 -0000 Received: (qmail 85640 invoked by uid 500); 18 Jan 2011 20:18:26 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 85579 invoked by uid 500); 18 Jan 2011 20:18:26 -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 85570 invoked by uid 99); 18 Jan 2011 20:18:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jan 2011 20:18:25 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [209.86.89.61] (HELO elasmtp-galgo.atl.sa.earthlink.net) (209.86.89.61) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jan 2011 20:18:16 +0000 Received: from [66.32.169.56] (helo=[192.168.2.50]) by elasmtp-galgo.atl.sa.earthlink.net with esmtpa (Exim 4.67) (envelope-from ) id 1PfI03-00012I-9w for log4j-user@logging.apache.org; Tue, 18 Jan 2011 15:17:55 -0500 Subject: Re: Directing logging of a single class to a different file From: Tim Watts To: Log4J Users List In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Organization: Clifton Farm Date: Tue, 18 Jan 2011 15:18:05 -0500 Message-ID: <1295381885.2976.126.camel@dellberry.cliftonfarm.net> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit X-ELNK-Trace: 3a5701426d89357f74bf435c0eb9d478492f6637d49f10f73a3e9a5febd1e5222ae876fa99b06adc350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 66.32.169.56 X-Virus-Checked: Checked by ClamAV on apache.org This may not be relevant but you have the logger for MyClass is declared twice. Try removing the 2nd one. On the other hand, it may be that log4j assumes the part after 'logger' is a package not a class? You could try using an xml config instead. But I would check the source code first (PropertiesConfigurator and Heirarchy or something like that -- been a while since I poked my nose in there). A lot of the code is remarkably straightforward. On Tue, 2011-01-18 at 14:31 -0500, Jorge Medina wrote: > Hello, > > I am trying to direct the output of a single class (MyClass) to a > different log file. > I added the following lines to my log4j configuration > > ############################################################################### > # Metrics Logger Appender > ############################################################################### > log4j.logger.com.example.interceptor.MyClass=DEBUG, R2 > log4j.appender.R2=org.apache.log4j.DailyRollingFileAppender > log4j.appender.R2.File=/some/path/metrics > log4j.appender.R2.DatePattern='-'yyyy-MM-dd'.log' > log4j.appender.R2.layout=org.apache.log4j.PatternLayout > log4j.appender.R2.layout.ConversionPattern=[%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}] > [%X{username}] [%X{clientId}] %-5p %c{1} %m%n > log4j.additivity.com.example.interceptor.MyClass=false > > ############################################################################### > # Metrics Logger Package Selection > ############################################################################### > log4j.logger.com.example.interceptor.MyClass=DEBUG > > But I get the error messages: > > log4j:WARN No appenders could be found for logger > (com.example.interceptor.MyClass). > log4j:WARN Please initialize the log4j system properly. > > Nevertheless it works when I remove the class name on the first line: > > ############################################################################### > # Metrics Logger Appender > ############################################################################### > log4j.logger.com.example.interceptor=DEBUG, R2 > log4j.appender.R2=org.apache.log4j.DailyRollingFileAppender > log4j.appender.R2.File=/some/path/metrics > log4j.appender.R2.DatePattern='-'yyyy-MM-dd'.log' > log4j.appender.R2.layout=org.apache.log4j.PatternLayout > log4j.appender.R2.layout.ConversionPattern=[%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ}] > [%X{username}] [%X{clientId}] %-5p %c{1} %m%n > log4j.additivity.com.example.interceptor.MyClass=false > > ############################################################################### > # Metrics Logger Package Selection > ############################################################################### > log4j.logger.com.example.interceptor.MyClass=DEBUG > > > But this has the side effect of logging the output of other classes in > the same package (com.example.interceptor). > I really just want the log statements of a single class (MyClass). > I can't figure what I am doing wrong. Any help is appreciated. > Thanks > > -Jorge > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-user-help@logging.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org