Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 29169 invoked from network); 2 Sep 2008 20:48:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Sep 2008 20:48:05 -0000 Received: (qmail 17335 invoked by uid 500); 2 Sep 2008 20:48:01 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 17312 invoked by uid 500); 2 Sep 2008 20:48:00 -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 17301 invoked by uid 99); 2 Sep 2008 20:48:00 -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 13:48:00 -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 [76.96.30.17] (HELO QMTA10.emeryville.ca.mail.comcast.net) (76.96.30.17) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Sep 2008 20:47:01 +0000 Received: from OMTA11.emeryville.ca.mail.comcast.net ([76.96.30.36]) by QMTA10.emeryville.ca.mail.comcast.net with comcast id 9v791a00P0mlR8UAAwnWWl; Tue, 02 Sep 2008 20:47:30 +0000 Received: from [172.16.1.36] ([70.143.38.4]) by OMTA11.emeryville.ca.mail.comcast.net with comcast id 9wnL1a00q05NPJW8XwnPgU; Tue, 02 Sep 2008 20:47:28 +0000 X-Authority-Analysis: v=1.0 c=1 a=-WA5kl6jJSIA:10 a=JOpdfbsy3AUA:10 a=2AaBzf350Rkb5yJh94EA:9 a=PuZIzYt1DGXwcc2PTlMA:7 a=Q1t4p9QpNTdnnlJNu8IXzGxKDz4A:4 a=GYzAc3ckfYUA:10 a=WuK_CZDBSqoA:10 Message-Id: <2F3ED5DA-2BD4-4FB1-A12B-79C29B0C23CD@apache.org> From: Curt Arnold To: "Log4J Users List" In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v928.1) Subject: Re: DEBUG messages appearing on console? Date: Tue, 2 Sep 2008 15:47:20 -0500 References: X-Mailer: Apple Mail (2.928.1) X-Virus-Checked: Checked by ClamAV on apache.org 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=WARN, CA > log4j.appender.CA=org.apache.log4j.ConsoleAppender > log4j.appender.CA.layout=org.apache.log4j.PatternLayout > log4j.appender.CA.layout.ConversionPattern=%-5p %d{yyyy-MM-dd > HH:mm:ss} [%t] > %c%n\t{%m}%n%n > > # LinkHarvester > log4j.logger.com.dsn.loadlink=DEBUG, harvester > log4j.appender.harvester=org.apache.log4j.RollingFileAppender > log4j.appender.harvester.File=C:/log4j/logs/LinkHarvester.log > log4j.appender.harvester.MaxFileSize=100KB > log4j.appender.harvester.MaxBackupIndex=1 > log4j.appender.harvester.layout=org.apache.log4j.PatternLayout > log4j.appender.harvester.layout.ConversionPattern=%-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=DEBUB, CA, harvester > log4j.appender.CA=org.apache.log4j.ConsoleAppender > log4j.appender.CA.layout=org.apache.log4j.PatternLayout > log4j.appender.CA.layout.ConversionPattern=%-5p %d{yyyy-MM-dd > HH:mm:ss} [%t] > %c%n\t{%m}%n%n log4j.appender.threshold=INFO > log4j.appender.harvester=org.apache.log4j.RollingFileAppender > log4j.appender.harvester.File=C:/log4j/logs/LinkHarvester.log > log4j.appender.harvester.MaxFileSize=100KB > log4j.appender.harvester.MaxBackupIndex=1 > log4j.appender.harvester.layout=org.apache.log4j.PatternLayout > log4j.appender.harvester.layout.ConversionPattern=%-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