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 D800018628 for ; Thu, 14 Jan 2016 02:49:16 +0000 (UTC) Received: (qmail 286 invoked by uid 500); 14 Jan 2016 02:49:16 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 230 invoked by uid 500); 14 Jan 2016 02:49:16 -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 219 invoked by uid 99); 14 Jan 2016 02:49:16 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2016 02:49:16 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 02633C17C4 for ; Thu, 14 Jan 2016 02:49:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3 X-Spam-Level: *** X-Spam-Status: No, score=3 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id Tfj6vnijrgC9 for ; Thu, 14 Jan 2016 02:49:03 +0000 (UTC) Received: from COL004-OMC3S13.hotmail.com (col004-omc3s13.hotmail.com [65.55.34.151]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id F391F31AB5 for ; Thu, 14 Jan 2016 02:49:02 +0000 (UTC) Received: from COL126-W17 ([65.55.34.137]) by COL004-OMC3S13.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Wed, 13 Jan 2016 18:48:55 -0800 X-TMN: [jnTL/FPHWGRqFZjJ5k8AamUxqtBLH8nK] X-Originating-Email: [nickdu@msn.com] Message-ID: Content-Type: multipart/alternative; boundary="_bd5b66df-88e8-4262-9ff0-233c1d23846e_" From: Nicholas Duane To: Log4J Users List Subject: RE: Appender's append() method Date: Wed, 13 Jan 2016 21:48:54 -0500 Importance: Normal In-Reply-To: References: ,, MIME-Version: 1.0 X-OriginalArrivalTime: 14 Jan 2016 02:48:55.0241 (UTC) FILETIME=[1BF20B90:01D14E76] --_bd5b66df-88e8-4262-9ff0-233c1d23846e_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks for the info. What about the compiler problem which appears to be d= ue to the fact that the append() method is not marked as throwing exception= s? Thanks=2C Nick > Date: Wed=2C 13 Jan 2016 14:17:47 -0800 > Subject: Re: Appender's append() method > From: garydgregory@gmail.com > To: log4j-user@logging.apache.org >=20 > IMO a RuntimeException subclass is appropriate while RuntimeException > should not be used. >=20 > Gary >=20 > On Wed=2C Jan 13=2C 2016 at 1:53 PM=2C Ralph Goers > wrote: >=20 > > Your appender is automatically wrapped by an AppenderControl object. Th= e > > AppenderControl will inspect the ignoreExceptions flag so your Appender > > does not have to. Your Appender should just throw a RuntimeException i= f it > > encounters a problem. > > > > Ralph > > > > > On Jan 13=2C 2016=2C at 2:38 PM=2C Nicholas Duane wr= ote: > > > > > > I'm new to java so maybe this should be an obvious question to most j= ava > > developers. If I'm trying to override the append() method but also thr= ow > > exceptions=2C how is that done? > > > > > > I'm asking because I assume my append method's outermost catch block = is > > to inspect the ignoreExceptions flag and either bubble up the exception= if > > ignoreExceptions is false or eat the exception otherwise=2C most likely= just > > logging an event. Is that true? If so=2C then how do I accomplish tha= t? I > > tried coding it as I mentioned above (actually someone else did it for = me)=2C > > but the compiler I guess was complaining about the throw needing to be = in a > > catch block=2C I assume because the append() method is not defined to t= hrow > > exceptions. > > > > > > In addition=2C looking at what I think was source for one of your > > appenders at: > > > > > > > > https://git-wip-us.apache.org/repos/asf?p=3Dlogging-log4j2.git=3Ba=3Dbl= ob=3Bf=3Dlog4j-core/src/main/java/org/apache/logging/log4j/core/appender/Ab= stractOutputStreamAppender.java=3Bh=3D9a4cfde83194c866c30c4687e9f4ebb19cb20= a17=3Bhb=3D75d33d96ac00356014cf11f8ad9e8c6ead4db37a > > > > > > Why does it always throw an exception in the catch block instead of > > checking the state of the ignoreExceptions flag? > > > > > > Thanks=2C > > > Nick > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe=2C e-mail: log4j-user-unsubscribe@logging.apache.org > > For additional commands=2C e-mail: log4j-user-help@logging.apache.org > > > > >=20 >=20 > --=20 > E-Mail: garydgregory@gmail.com | ggregory@apache.org > Java Persistence with Hibernate=2C Second Edition > > JUnit in Action=2C Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory = --_bd5b66df-88e8-4262-9ff0-233c1d23846e_--