logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Premdas <Andrew.Prem...@teleca.com>
Subject RE: Logging Exceptions
Date Wed, 05 Sep 2001 15:33:29 GMT
The choice is not about which exceptions I want to log, but how the
exceptions I have decided will be logged are displayed.

I am looking for a global setting in configuration that would change the way
all exceptions were logged when called by cat.xxx(m,t). So you could turn on
an off the stack trace logging. Currently you have to decide in code i.e.
cat.xxx(t) no stack trace cat.xxx(m,t) stack trace.

I have created ExceptionWithLogging class which all my Exceptions I want to
log can extend, so they will have in built logging (logging statement called
in constructor) and you don't have to write code like

catch (myException m){
  cat.xxx("Exception", m)
}

all the time as its already done. This also has advantage you don't need to
include the log4j library stuff in every file that you want to log
exceptions. However log now will get every stack trace of all my logged
exceptions. Would like this to be configurable as stack traces can be quite
large.

The choice about which exceptions I want to log is made by calling a logging
statement when I catch an exception.

If I want to turn of logging of all my exceptions then I can do this in the
config file by setting the threshold for ExceptionWithLogging.

I haven't considered a way of automatically logging java library exceptions
such as the ones you mention - can this be done?

Hope this clarifies things

Andrew

-----Original Message-----
From: Jon Skeet [mailto:jon.skeet@peramon.com]
Sent: 05 September 2001 13:20
To: LOG4J Users Mailing List
Subject: RE: Logging Exceptions


> I'm afraid you'd still have to make the choice in coding 
> simply because
> you may not want to log some exceptions, but may want to log others. I
> could see your point though if you were advocating configuring the
> logging of exceptions on a class-by-class bases.
> 
> For example you may want to enable logging for java.sql.SQLException,
> but disable it for java.lang.ClassCastException. Is this what you had
> in mind?

Note - this is something that would be possible if my suggestions in the
Dev mailing list about having ThrowableRenderers (or whatever) and being
able to configure renderers get taken up :)

Jon



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

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


Mime
View raw message