Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 10097 invoked from network); 7 Jul 2004 16:47:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Jul 2004 16:47:33 -0000 Received: (qmail 10742 invoked by uid 500); 7 Jul 2004 16:22:28 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 10532 invoked by uid 500); 7 Jul 2004 16:22:26 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 10393 invoked by uid 99); 7 Jul 2004 16:22:24 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [12.2.83.3] (HELO gw.optimalinternet.com) (12.2.83.3) by apache.org (qpsmtpd/0.27.1) with ESMTP; Wed, 07 Jul 2004 09:22:19 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [logging] [digester maybe?] Is this correct syntax for commons-logging? Date: Wed, 7 Jul 2004 12:22:15 -0400 Message-ID: From: "Mark Horn" To: "Jakarta Commons Users List" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N It is because you have your rootLogger set to DEBUG. =20 log4j.rootLogger=3DDEBUG, GuiAppender I would suggest setting you rootLogger to ERROR And setting a logger for your package Example:=20 Log4j.rootLogger=3DERROR, GuiAppender log4j.logger.com.mycompany.mypackage=3DDEBUG Mark Horn -----Original Message----- From: Dan Tarkenton [mailto:dant@tarksoft.com]=20 Sent: Wednesday, July 07, 2004 12:00 PM To: commons-user@jakarta.apache.org Subject: [logging] [digester maybe?] Is this correct syntax for commons-logging? Hello all. I have a web app that uses Log4J. I realize that commons-logging.jar=20 just provides an interface on top of a logging implementation such as=20 Log4J. I am pretty sure that my commons-logging related syntax is what=20 is preventing me from controlling logging. You see, I am also using=20 Apache Digester, and since Apache Digester uses commons-logging, it=20 seems to be finding my log4j.properties configuration file, and=20 automatically logging everything at the DEBUG level. I assume it's just finding the root logger of Log4J, and not my "class level" logger. I am trying to control that level of logging to only include ERROR level and=20 above. I know this _sounds_ like a log4J problem, but I really believe I must=20 be using commons-logging API incorrectly. Take a look at my syntax for=20 adding a logger to my Digester object: public class TestResultsHandler implements MessageResourcesKeys { =20 static final Logger logger =3D=20 Logger.getLogger(TestResultsHandler.class.getName()); . . . public static Digester initializeParser() { =20 Digester digester =3D new Digester(); =20 digester.setLogger(new Log4JLogger(logger)); digester.setValidating(true); digester.setErrorHandler(new TestResultsErrorHandler()); // configure digester rules . . . return digester; } public static void parse(String document) throws TestResultsException { =20 Digester digester =3D initializeParser(); TestResultsHandler resultsParser =3D null; try { =20 //resultsParser =3D (TestResultsHandler)digester.parse(new=20 StringReader(document)); resultsParser =3D (TestResultsHandler)digester.parse(new=20 File("/usr/local/projects/BOMAnalysis/web/xml/TestResults.xml")); } catch (SAXParseException saxe) { String msg =3D=20 MessageUtil.formatMessage(MSG_TEST_RESULTS_PARSER_FAILURE); throw new TestResultsException(msg, saxe); } catch (SAXException saxe) { String msg =3D=20 MessageUtil.formatMessage(MSG_TEST_RESULTS_PARSER_FAILURE); throw new TestResultsException(msg, saxe); } catch (IOException ioe) { String msg =3D=20 MessageUtil.formatMessage(MSG_TEST_RESULTS_IO_FAILURE); throw new TestResultsException(msg, ioe); =20 } } } Here are the contents of my log4j.properties file in WEB-INF\classes: log4j.rootLogger=3DDEBUG, GuiAppender =20 # GuiAppender is set to be a FileAppender. log4j.appender.GuiAppender=3Dorg.apache.log4j.FileAppender log4j.appender.GuiAppender.Append=3Dtrue log4j.appender.GuiAppender.File=3D/usr/local/projects/BOMAnalysis/logs/gu= i .log # PmA1 uses PatternLayout. log4j.appender.GuiAppender.layout=3Dorg.apache.log4j.PatternLayout log4j.appender.GuiAppender.layout.ConversionPattern=3D%d: %-5p : %m%n log4j.logger.com.titan.bat.gui.testresults.TestResultsHandler=3DERROR No matter what level I set the LEVEL for=20 log4j.logger.com.titan.bat.gui.testresults.TestResultsHandler, I always=20 get DEBUG messages which makes me believe the Digester is defaulting to=20 the root logger of Log4J. As a matter of fact, if I take out the code=20 for setting the logger for the digester, it will still log at the DEBUG=20 level. This is why I think my use of the commons-logging api is=20 incorrect. I think perhaps I'm incorrectly setting the logger for the=20 Digester object. I have certainly named a logger,=20 com.titan.bat.gui.testresults.TestResultsHandler in this properties=20 file; is this not the same logger that is referenced as the static=20 logger member of my TestResultsHandler class? Thanks in advance for any insight you may be able to provide. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org