From log4j-user-return-24495-apmail-logging-log4j-user-archive=logging.apache.org@logging.apache.org Fri Jun 8 17:00:48 2012 Return-Path: X-Original-To: apmail-logging-log4j-user-archive@www.apache.org Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3741BCA2B for ; Fri, 8 Jun 2012 17:00:48 +0000 (UTC) Received: (qmail 97535 invoked by uid 500); 8 Jun 2012 17:00:47 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 97486 invoked by uid 500); 8 Jun 2012 17:00:47 -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 97474 invoked by uid 99); 8 Jun 2012 17:00:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 17:00:47 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of hoju@visi.com designates 208.42.184.244 as permitted sender) Received: from [208.42.184.244] (HELO g2host.com) (208.42.184.244) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 17:00:41 +0000 Received: from [162.136.192.1] (account hoju@visi.com) by mailback4.g2host.com (CommuniGate Pro WEBUSER 5.3.11) with HTTP id 7585006 for log4j-user@logging.apache.org; Fri, 08 Jun 2012 12:00:19 -0500 From: "Jacob Kjome" Subject: Re: class specific logging level To: "Log4J Users List" X-Mailer: CommuniGate Pro WebUser v5.3.11 Date: Fri, 08 Jun 2012 12:00:19 -0500 Message-ID: In-Reply-To: <33982558.post@talk.nabble.com> References: <33974515.post@talk.nabble.com> <33979415.post@talk.nabble.com> <33982398.post@talk.nabble.com> <33982558.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1; format="flowed" Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org First, you are not setting the level of the appender, but that of the logger which can reference any given appender, including your named "Log1" appender.  So, if you want ERROR level for all classes, then set the "root" logger level to ERROR.  After that, you make a decision of which appenders you want logging to go to (disregarding level, as that is the job of the logger - except in regard to more advanced configuration where you can set appender level thresholds or use filters, but that's beyond our discussion here).  If you want output of all classes (again, disregarding level) to go to the "Log1", then you provide a reference to "Log1" in the primordial "root" logger. After that, if you want to lower the level for specific loggers, you can specify those as you've done with "com.pkg.MyClass".  Now all classes, including "com.pkg.MyClass" will log at the ERROR level, but "com.pkg.MyClass" will also provide DEBUG, INFO, and WARN (and SEVERE) logging as well. This is all very standard stuff.  If you don't experience the above behavior, then I would suspect that the Log4j configuration you think you are using isn't being used at all.  You might want to use... -Dlog4j.debug=true This will tell Log4j to report how it is being configured.  You may find that some other configuration is being used instead of yours.  Either that, or you are not describing what you want clearly enough. Jake On Fri, 8 Jun 2012 09:15:14 -0700 (PDT)  aggarwal wrote: > > > If I set the level of Log1 appender to DEBUG, then DEBUG logs of all the > classes including MyClass are getting logged. If I set it to ERROR, then > ERROR logs of all the classes including MyClass are getting logged. But what > I want is - DEBUG logs of only MyClass and ERROR of rest all. Here, my > motive is to set DEBUG level logging for most important classes helping in > debugging procedure. > > > > > > > private final static Logger logger = Logger.getLogger(MyClass.class); > > This is how a logger is defined in my code. It was my mistake to replace > "com.pkg.MyClass" with "MyClass". > > Thanks for "additivity" and "priority" related suggestions. > > Actually, root isn't my concern here. No matter what the level of root and > appender is, I want DEBUG logs of only MyClass. > > > > > > Douglas E Wegscheid wrote: >> >>> I want MyClass logs of DEBUG level and all other classes of ERROR in >>> "log1.log" file as mentioned in logger "Log1". >>> ... >>> whereas if I set the level in appender >>> "Log1" to DEBUG, I do get the DEBUG logs of Myclass in log1.log. >> >> If you set the level of the Log1 appender to DEBUG, you say that you get >> the DEBUG logs of Myclass in log1.log. Isn't that what you want? >> > > -- > View this message in context: >http://old.nabble.com/class-specific-logging-level-tp33974515p33982558.html > Sent from the Log4j - Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > 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