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 C33E318A98 for ; Thu, 14 Jan 2016 05:48:43 +0000 (UTC) Received: (qmail 61311 invoked by uid 500); 14 Jan 2016 05:48:43 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 61259 invoked by uid 500); 14 Jan 2016 05:48:43 -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 61248 invoked by uid 99); 14 Jan 2016 05:48:43 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2016 05:48:43 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EF7781A0726 for ; Thu, 14 Jan 2016 05:48:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.001 X-Spam-Level: X-Spam-Status: No, score=0.001 tagged_above=-999 required=6.31 tests=[URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 1OtH2PIm__6a for ; Thu, 14 Jan 2016 05:48:30 +0000 (UTC) Received: from smtp687.redcondor.net (smtp687.redcondor.net [208.80.206.87]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTPS id 68A5D43BFE for ; Thu, 14 Jan 2016 05:48:30 +0000 (UTC) Received: from mailproxy11.neonova.net ([137.118.22.76]) by smtp687.redcondor.net ({f50aeeea-7a14-4dd3-bdda-1246754c15b3}) via TCP (outbound) with ESMTP id 20160114054829064_0687 for ; Thu, 14 Jan 2016 05:48:29 +0000 X-RC-FROM: X-RC-RCPT: Received: from [192.168.1.14] (ip72-201-43-179.ph.ph.cox.net [72.201.43.179]) (Authenticated sender: ralph.goers@dslextreme.com) by mailproxy11.neonova.net (Postfix) with ESMTPA id 7CCFF360077 for ; Thu, 14 Jan 2016 00:48:25 -0500 (EST) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: Appender's append() method From: Ralph Goers In-Reply-To: Date: Wed, 13 Jan 2016 22:48:24 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <3ADF4420-17E2-4445-A696-0394C2730436@dslextreme.com> References: To: Log4J Users List X-Mailer: Apple Mail (2.2104) X-DLP-ENABLED: 137.118.22.64/27 X-MAG-OUTBOUND: greymail.redcondor.net@137.118.22.64/27 What compiler problem? There is no compiler problem if a subclass of a = RuntimeException is thrown. Appender=92s shouldn=92t be throwing checked = exceptions. Ralph > On Jan 13, 2016, at 7:48 PM, Nicholas Duane wrote: >=20 > Thanks for the info. What about the compiler problem which appears to = be due to the fact that the append() method is not marked as throwing = exceptions? >=20 > Thanks, > Nick >=20 >> Date: Wed, 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, Jan 13, 2016 at 1:53 PM, Ralph Goers = >> wrote: >>=20 >>> Your appender is automatically wrapped by an AppenderControl object. = The >>> AppenderControl will inspect the ignoreExceptions flag so your = Appender >>> does not have to. Your Appender should just throw a = RuntimeException if it >>> encounters a problem. >>>=20 >>> Ralph >>>=20 >>>> On Jan 13, 2016, at 2:38 PM, Nicholas Duane wrote: >>>>=20 >>>> I'm new to java so maybe this should be an obvious question to most = java >>> developers. If I'm trying to override the append() method but also = throw >>> exceptions, how is that done? >>>>=20 >>>> 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, most = likely just >>> logging an event. Is that true? If so, then how do I accomplish = that? I >>> tried coding it as I mentioned above (actually someone else did it = for me), >>> but the compiler I guess was complaining about the throw needing to = be in a >>> catch block, I assume because the append() method is not defined to = throw >>> exceptions. >>>>=20 >>>> In addition, looking at what I think was source for one of your >>> appenders at: >>>>=20 >>>>=20 >>> = https://git-wip-us.apache.org/repos/asf?p=3Dlogging-log4j2.git;a=3Dblob;f=3D= log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractOu= tputStreamAppender.java;h=3D9a4cfde83194c866c30c4687e9f4ebb19cb20a17;hb=3D= 75d33d96ac00356014cf11f8ad9e8c6ead4db37a >>>>=20 >>>> Why does it always throw an exception in the catch block instead of >>> checking the state of the ignoreExceptions flag? >>>>=20 >>>> Thanks, >>>> Nick >>>>=20 >>>=20 >>>=20 >>>=20 >>> = --------------------------------------------------------------------- >>> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org >>> For additional commands, e-mail: log4j-user-help@logging.apache.org >>>=20 >>>=20 >>=20 >>=20 >> --=20 >> E-Mail: garydgregory@gmail.com | ggregory@apache.org >> Java Persistence with Hibernate, Second Edition >> >> JUnit in Action, Second Edition >> Spring Batch in Action >> Blog: http://garygregory.wordpress.com >> Home: http://garygregory.com/ >> Tweet! http://twitter.com/GaryGregory > =20 --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org