logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Naming loggers / resolving calling classes
Date Wed, 09 Apr 2003 16:09:52 GMT

Have you looked into object renderers in log4j?  That'll get you back in
the "handle" space you're used to.  See

A simple implementation of an ObjectRenderer can just do
obj.getClass().getName() + obj.toString()

Yoav Shapira
Millennium ChemInformatics

>-----Original Message-----
>From: Jonathan Whitall [mailto:fiddlerpianist@yahoo.com]
>Sent: Wednesday, April 09, 2003 11:21 AM
>To: Log4J Users List
>Subject: RE: Naming loggers / resolving calling classes
>--- "Shapira, Yoav" <Yoav.Shapira@mpi.com> wrote:
>> Howdy,
>> How about adding getClass().getName() to every
>> logging call inside your
>> classes?
>> Yoav Shapira
>> Millennium ChemInformatics
>Well, I could do that, but that would put the
>responsibility for making sure that the class name is
>pre-prepended to every message that I am logging.
>So when I go to log, my code would look something
>log.info(formatMessage(this, "My message"));
>instead of just
>log.info("My message");
>The types of loggers that I am used to working with
>have the option of passing a handle to the current
>calling object, and then the logging system itself is
>configured to render that object handle in the format
>desired, not the caller.  Something like this:
>log.info(this, "My message");
>Obviously, Log4j doesn't take the object handle at
>all, so I have to work around it some way.  I would
>rather not leave formatting up to the caller.
>Jonathan Whitall
>Do you Yahoo!?
>Yahoo! Tax Center - File online, calculators, forms, and more
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.

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

View raw message