You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Luke Blanshard <lu...@quiq.com> on 2001/01/17 21:55:21 UTC

Re: feature request: additional category methods that take Throwable objs

John Lindsey wrote:

> I would like category methods that take only an exception:
>
>         debug( Throwable t )
>         etc..( Throwable t )
>
> I got bit by this just now...I thought that these methods were already in
> Category, so I had a bunch of log statements that I was just passing an
> exception to, with the hope that they would print out the exception message
> and stack trace.
>
> It seems that these methods would be useful, since often the Exception
> message and stack trace are all you want to log.

I just got bit by this today too.  Ceki, we had this conversation a year ago,
I recall.  I'm still in favor of this change---I find the current behavior
completely unintuitive.

Luke


Re: feature request: additional category methods thattakeThrowable objs

Posted by Luke Blanshard <lu...@quiq.com>.
Ceki Gulcu wrote:

> Contrary to my earlier promise, I have decided not to introduce printing
> methods taking just a Throwable argument.  I think the advantage introduced
> by these methods is minor. I want to avoid adding new methods to the
> Category class which is already quite bloated. Moreover, once something
> gets into category it cannot be easily removed and affects the rest of the
> package plus all future and current sub-classes.

The good news is, log4j is open source, so you can patch it to make the API
usable.

Luke


Re: feature request: additional category methods that takeThrowable objs

Posted by Ceki Gulcu <cg...@urbanet.ch>.
At 13:47 18.01.2001 +0000, you wrote:


>Ceki Gulcu wrote:
> >
> > You got bitten by this today? Are you suggesting that this keeps happening?
> > I wonder if it happens consistently to other users... Ceki
> >
>Hi,
>
>I've just started using log4j - been aware of it for some time but was
>waiting to see if the java logging apis came to anything and whether
>any worthwhile standard would emerge. I converted my first lot of code
>yesterday and this was one of the first things I noticed, as I was
>converting catch blocks with a single "e.printStackTrace()" in them to
>use the logger and had to think up suitable messages for the first
>parameter. I looked through the Category api and was also mildly
>surprised to see that there were no methods purely for logging
>exceptions. In a lot of try/catch blocks I have a last catch for
>Throwable or Exception and having to put in the message "Unexpected
>exception while <blah>" doesn't really seem to add that much. Whether
>it's preferable to *always* have some message or not I don't know, but
>it might be better to have the option of doing either.

Luke,

Contrary to my earlier promise, I have decided not to introduce printing 
methods taking just a Throwable argument.  I think the advantage introduced 
by these methods is minor. I want to avoid adding new methods to the 
Category class which is already quite bloated. Moreover, once something 
gets into category it cannot be easily removed and affects the rest of the 
package plus all future and current sub-classes.

Flames exceptionally welcome. :-) Ceki

----
Ceki Gülcü (cgu@urbanet.ch)


Re: feature request: additional category methods thattakeThrowable objs

Posted by Luke Taylor <ne...@freesurf.ch>.

Ceki Gulcu wrote:
> 
> At 13:47 18.01.2001 +0000, you wrote:
> 
> >Ceki Gulcu wrote:
> 
> I did not know that jBoss came with log4j? jBoss 2.0 is not shipped with
> it. Which version are you referring to? Cheers, Ceki
> 

Thanks for the info.

The current pre-2.1 version of jboss from cvs has log4j.jar included.
It's not referenced in the source anywhere, but seems to be referenced
in "exolab" whatever that is.

Luke.


-- 
 Luke Taylor.
 PGP Key ID: 0x57E9523C

Re: feature request: additional category methods that takeThrowable objs

Posted by Ceki Gulcu <cg...@urbanet.ch>.
At 13:47 18.01.2001 +0000, you wrote:


>Ceki Gulcu wrote:
> >
> > You got bitten by this today? Are you suggesting that this keeps happening?
> > I wonder if it happens consistently to other users... Ceki
> >
>Hi,
>
>I've just started using log4j - been aware of it for some time but was
>waiting to see if the java logging apis came to anything and whether
>any worthwhile standard would emerge. I converted my first lot of code
>yesterday and this was one of the first things I noticed, as I was
>converting catch blocks with a single "e.printStackTrace()" in them to
>use the logger and had to think up suitable messages for the first
>parameter. I looked through the Category api and was also mildly
>surprised to see that there were no methods purely for logging
>exceptions. In a lot of try/catch blocks I have a last catch for
>Throwable or Exception and having to put in the message "Unexpected
>exception while <blah>" doesn't really seem to add that much. Whether
>it's preferable to *always* have some message or not I don't know, but
>it might be better to have the option of doing either.

I am aware that the lack of methods for printing an exception without an 
accompanying message surprises new users. Every tool has its idiosyncrasies 
and log4j has its own rich set of quirks. In this particular case I believe 
that the tradeoff is between better usability and lesser API consistence as 
an exception is treated completely independently from the log message 
passed as a parameter. I wanted to avoid giving the impression that an 
exception could somehow be the log message. However, if that is the 
behavior users naturally expect, then log4j should offer the additional 
exception printing methods. You can expect this addition for the next release.


>In any case it's a small point and I'd like to say I was very pleased
>with it and the overall design and configuration stuff. Nice and easy
>to use and stillv very powerful. I've been delaying putting proper
>logging into my code for some time and it feels good to finally have
>got it together and made the decision on what to use. With log4j being
>part of the jakarta project now I'm sure it's bound to catch on more
>widely and become a de facto standard. Do you know if there are any
>plans to use it in any of the other projects, like tomcat? I've noticed
>it comes with the JBoss EJB server, but not sure to what extent it's
>used there.

I have heard through the grapevine that Tomcat and a bunch of other 
projects are switching to log4j but I am really not a reliable source. :-)

I did not know that jBoss came with log4j? jBoss 2.0 is not shipped with 
it. Which version are you referring to? Cheers, Ceki

---
Freedom as in the capacity to exercise choice.


Re: feature request: additional category methods that takeThrowable objs

Posted by Luke Taylor <ne...@freesurf.ch>.

Ceki Gulcu wrote:
> 
> You got bitten by this today? Are you suggesting that this keeps happening?
> I wonder if it happens consistently to other users... Ceki
> 
Hi,

I've just started using log4j - been aware of it for some time but was
waiting to see if the java logging apis came to anything and whether
any worthwhile standard would emerge. I converted my first lot of code
yesterday and this was one of the first things I noticed, as I was
converting catch blocks with a single "e.printStackTrace()" in them to
use the logger and had to think up suitable messages for the first
parameter. I looked through the Category api and was also mildly
surprised to see that there were no methods purely for logging
exceptions. In a lot of try/catch blocks I have a last catch for
Throwable or Exception and having to put in the message "Unexpected
exception while <blah>" doesn't really seem to add that much. Whether
it's preferable to *always* have some message or not I don't know, but
it might be better to have the option of doing either.

In any case it's a small point and I'd like to say I was very pleased
with it and the overall design and configuration stuff. Nice and easy
to use and stillv very powerful. I've been delaying putting proper
logging into my code for some time and it feels good to finally have
got it together and made the decision on what to use. With log4j being
part of the jakarta project now I'm sure it's bound to catch on more
widely and become a de facto standard. Do you know if there are any
plans to use it in any of the other projects, like tomcat? I've noticed
it comes with the JBoss EJB server, but not sure to what extent it's
used there.

cheers,

Luke.

-- 
 Luke Taylor.
 PGP Key ID: 0x57E9523C

RE: feature request: additional category methods that takeThrowable objs

Posted by Robert Loren <rl...@niku.com>.
Hi all,

Just one cent I guess: How bout an ObjectRenderer?
Rob

P.S. Thanks for Log4j!

Robert Loren
Software Engineer
NIKU Corporation
847-572-6694
rloren@niku.com


-----Original Message-----
From: Aston Chan [mailto:achan@altaworks.com]
Sent: Wednesday, January 17, 2001 4:15 PM
To: LOG4J Users Mailing List
Subject: Re: feature request: additional category methods that
takeThrowable objs



I do find it inconvenient to have to specify a String before the
exception.  It will be nice to have a method that only takes a Throwable.

The way I used log4j is to have a wrapper class for the internals of log4j.
My wrapper class define a  method like   error(Throwable t) so all my
clients can just call this method with an Exception.  Inside my wrapper
class, I do a cat.error("", t);

My 2 cents.

-Aston


----- Original Message -----
From: "Luke Blanshard" <lu...@quiq.com>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Wednesday, January 17, 2001 4:59 PM
Subject: Re: feature request: additional category methods that takeThrowable
objs


> Ceki Gulcu wrote:
>
> > You got bitten by this today? Are you suggesting that this keeps
happening?
> > I wonder if it happens consistently to other users... Ceki
>
> I saw a log message that consisted of the string form of an exception, and
when
> I looked at the code whoever had written it just had category.error(
exception ).
> So yes, it keeps happening---every new programmer has to learn that you
must
> supply some extra string with an exception, or it will be logged
differently from
> usual.
>
> Luke
>
>
> ---------------------------------------------------------------------
> 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



Re: feature request: additional category methods that takeThrowable objs

Posted by Aston Chan <ac...@altaworks.com>.
I do find it inconvenient to have to specify a String before the
exception.  It will be nice to have a method that only takes a Throwable.

The way I used log4j is to have a wrapper class for the internals of log4j.
My wrapper class define a  method like   error(Throwable t) so all my
clients can just call this method with an Exception.  Inside my wrapper
class, I do a cat.error("", t);

My 2 cents.

-Aston


----- Original Message -----
From: "Luke Blanshard" <lu...@quiq.com>
To: "LOG4J Users Mailing List" <lo...@jakarta.apache.org>
Sent: Wednesday, January 17, 2001 4:59 PM
Subject: Re: feature request: additional category methods that takeThrowable
objs


> Ceki Gulcu wrote:
>
> > You got bitten by this today? Are you suggesting that this keeps
happening?
> > I wonder if it happens consistently to other users... Ceki
>
> I saw a log message that consisted of the string form of an exception, and
when
> I looked at the code whoever had written it just had category.error(
exception ).
> So yes, it keeps happening---every new programmer has to learn that you
must
> supply some extra string with an exception, or it will be logged
differently from
> usual.
>
> Luke
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>


Re: feature request: additional category methods that takeThrowable objs

Posted by Luke Blanshard <lu...@quiq.com>.
Ceki Gulcu wrote:

> You got bitten by this today? Are you suggesting that this keeps happening?
> I wonder if it happens consistently to other users... Ceki

I saw a log message that consisted of the string form of an exception, and when
I looked at the code whoever had written it just had category.error( exception ).
So yes, it keeps happening---every new programmer has to learn that you must
supply some extra string with an exception, or it will be logged differently from
usual.

Luke


Re: feature request: additional category methods that take Throwable objs

Posted by Ceki Gulcu <cg...@urbanet.ch>.
At 12:55 17.01.2001 -0800, you wrote:
>John Lindsey wrote:
>
> > I would like category methods that take only an exception:
> >
> >         debug( Throwable t )
> >         etc..( Throwable t )
> >
> > I got bit by this just now...I thought that these methods were already in
> > Category, so I had a bunch of log statements that I was just passing an
> > exception to, with the hope that they would print out the exception message
> > and stack trace.
> >
> > It seems that these methods would be useful, since often the Exception
> > message and stack trace are all you want to log.
>
>I just got bit by this today too.  Ceki, we had this conversation a year ago,
>I recall.  I'm still in favor of this change---I find the current behavior
>completely unintuitive.

Luke,

You got bitten by this today? Are you suggesting that this keeps happening? 
I wonder if it happens consistently to other users... Ceki