logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <ralph.go...@dslextreme.com>
Subject Re: Appender's append() method
Date Wed, 13 Jan 2016 21:53:58 GMT
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.

Ralph 

> On Jan 13, 2016, at 2:38 PM, Nicholas Duane <nickdu@msn.com> wrote:
> 
> 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?
> 
> 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.
> 
> In addition, looking at what I think was source for one of your appenders at:
> 
> https://git-wip-us.apache.org/repos/asf?p=logging-log4j2.git;a=blob;f=log4j-core/src/main/java/org/apache/logging/log4j/core/appender/AbstractOutputStreamAppender.java;h=9a4cfde83194c866c30c4687e9f4ebb19cb20a17;hb=75d33d96ac00356014cf11f8ad9e8c6ead4db37a
> 
> Why does it always throw an exception in the catch block instead of checking the state
of the ignoreExceptions flag?
> 
> Thanks,
> Nick
> 		 	   		  



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message