Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 72384 invoked from network); 2 Sep 2008 21:58:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Sep 2008 21:58:24 -0000 Received: (qmail 18439 invoked by uid 500); 2 Sep 2008 21:58:19 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 18417 invoked by uid 500); 2 Sep 2008 21:58:19 -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 18406 invoked by uid 99); 2 Sep 2008 21:58:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Sep 2008 14:58:19 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [66.135.107.35] (HELO relay.xtl.com) (66.135.107.35) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Sep 2008 21:57:21 +0000 Received: from gecko.xtl.com ([192.168.10.227]) by xtl.com with MailEnable ESMTP; Tue, 02 Sep 2008 17:57:57 -0400 Received: from gecko.xtl.com ([192.168.40.16] helo=gecko.xtl.com) by ASSP-nospam; 2 Sep 2008 17:57:57 -0400 Subject: Re: DEBUG messages appearing on console? From: Patrick.Grimard@xtl.com Date: Tue, 2 Sep 2008 17:57:57 -0400 To: "Log4J Users List" Importance: Normal MIME-Version: 1.0 (Apple Message framework v928.1) Message-ID: X-MIMETrack: Serialize by Router on XTLMO2/XTL(Release 7.0.2FP1|January 10, 2007) at 09/02/2008 05:57:57 PM, Serialize complete at 09/02/2008 05:57:57 PM Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="US-ASCII"; delsp="yes"; format="flowed" X-Virus-Checked: Checked by ClamAV on apache.org Thanks Curt. I implemented your suggestion and got what I was looking for. Thanks David for your suggestion as well. Patrick Patrick ----- Original Message ----- From: Curt Arnold [carnold@apache.org] Sent: 09/02/2008 04:47 PM To: "Log4J Users List" Subject: Re: DEBUG messages appearing on console? On Sep 2, 2008, at 2:00 PM, Patrick.Grimard@xtl.com wrote: > > I'm trying to configure log4j so that DEBUG messages or lower > priority only > appear in a log file and not the console, and anything above DEBUG > appears on > the console. This is what my log4j.properties file looks like right > now, > however the DEBUG messages are still appearing on the console. I'm > using log4j > along with Commons Logging API if that makes any difference. > > # Set the root logger to the INFO level and CA to be it's appender > log4j.rootLogger=3DWARN, CA > log4j.appender.CA=3Dorg.apache.log4j.ConsoleAppender > log4j.appender.CA.layout=3Dorg.apache.log4j.PatternLayout > log4j.appender.CA.layout.ConversionPattern=3D%-5p %d{yyyy-MM-dd > HH:mm:ss} [%t] > %c%n\t{%m}%n%n > > # LinkHarvester > log4j.logger.com.dsn.loadlink=3DDEBUG, harvester > log4j.appender.harvester=3Dorg.apache.log4j.RollingFileAppender > log4j.appender.harvester.File=3DC:/log4j/logs/LinkHarvester.log > log4j.appender.harvester.MaxFileSize=3D100KB > log4j.appender.harvester.MaxBackupIndex=3D1 > log4j.appender.harvester.layout=3Dorg.apache.log4j.PatternLayout > log4j.appender.harvester.layout.ConversionPattern=3D%-5p %d{yyyy-MM-dd > HH:mm:ss} > [%t] %c%n\t{%m}%n%n The filter suggestion is a bit overkill for what you need. What is happening is that you are assigning a DEBUG threshold to all logging requests to loggers starting with "com.dsn.loadlink", all other loggers have a threshold of WARN. You are also attaching a ConsoleAppender to the root logger and a RollingFileAppender to "com.dsn.loadlink", but that is an independent action from setting the thresholds. So if you make a logging request on "com.dsn.loadlink" or a child logger, it is evaluated against the nearest specified threshold and if that is satisfied, then it is processed by all appenders attached in the hierarchy (unless additivity is set to false which will prevent appenders attached to parent loggers from seeing the event). You can set a threshold on the appender which is independent of the threshold on the logger. Unless you have a specific need to separate the appenders, I would attach them both to root, but set a threshold on the ConsoleAppender. > log4j.rootLogger=3DDEBUB, CA, harvester > log4j.appender.CA=3Dorg.apache.log4j.ConsoleAppender > log4j.appender.CA.layout=3Dorg.apache.log4j.PatternLayout > log4j.appender.CA.layout.ConversionPattern=3D%-5p %d{yyyy-MM-dd > HH:mm:ss} [%t] > %c%n\t{%m}%n%n log4j.appender.threshold=3DINFO > log4j.appender.harvester=3Dorg.apache.log4j.RollingFileAppender > log4j.appender.harvester.File=3DC:/log4j/logs/LinkHarvester.log > log4j.appender.harvester.MaxFileSize=3D100KB > log4j.appender.harvester.MaxBackupIndex=3D1 > log4j.appender.harvester.layout=3Dorg.apache.log4j.PatternLayout > log4j.appender.harvester.layout.ConversionPattern=3D%-5p %d{yyyy-MM-dd > HH:mm:ss} > [%t] %c%n\t{%m}%n%n > --------------------------------------------------------------------- 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