Hi Antoine

I dont have an example how to deal with new levels but annother point is 
important while wrapping. You have to use the overloaded method log(String 
callerFQCN, Priority level, Object message, Throwable t) where you pass as 
first parameter the name of the wrapper class. The renderer will skip back the 
stacktrace until found this class, so you get the real location of the source 
of the log message while rendering (replacing the pattern placeholders %F:%L).

part of a log wrapping-method by using a new field category:

        MDC.put( MDC_CATEGORY, aCat );
        try
        {
            aLogger.log( MyLoggerWrapper.class.getName(), level, aMsg, aExc );
        }
        finally
        {
            MDC.remove( MDC_CATEGORY );
        }

This method can be private within the logger. So you can have more 
sophisticated public methods like logHarmless(aMsg) which sets up the other 
needed parameters like level or error code (I assume a logHarmless does not 
need an "ErrorCode") and calls then the above private method.

The reference "aLogger" can also be passed to the wrapper, or you can have a 
private var within the wrapper. Then you have only one logger instance for the 
whole application (and loosing the abililty of finetuning which class/package 
logs in which level, etc.).

Heri

> -----Original Message-----
> From: Antoine TYNEVEZ [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 20, 2005 9:43 AM
> To: Log4J Users List
> Subject: RE: Extend or Wrap
> 
> 
> Actually, I need to have something like :
> --------------------------------------------------------------
> --------------
> -------------------------------
>       logger.harmless("my message", "ERROR CODE", "PARAM2");
>       logger.minor("my message", "ERROR CODE", "PARAM2");
> --------------------------------------------------------------
> --------------
> -------------------------------
> 
> These methods use the MDC class to pass arguments to logger.
> 
> Could you show me how to wrap Log4j in this case ?
> 
> Thanks
> 
> Antoine
> 
> -----Message d'origine-----
> De : Lutz Michael [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 19 avril 2005 18:54
> A : 'Log4J Users List'
> Objet : RE: Extend or Wrap
> 
> 
> 
> It's not necessary to either extend or wrap Logger for using your own
> levels, unless you feel the need to add methods specifically 
> for your new
> levels.
> If so, it's still recommend to wrap Log4j instead of extending.
> There are technical issues known to be associated with 
> extending Log4j.
> 
> The solution I maintain at work (based on Log4j) uses a set 
> of "new" levels
> and we wrap Log4j, we don't extend.  We learned the hard way 
> a while back
> not to extend.
> 
> -----Original Message-----
> From: Antoine TYNEVEZ [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 19, 2005 11:33 AM
> To: Log4J Users List
> Subject: RE: Extend or Wrap
> 
> 
> Hi,
> 
> In my case, I must use my own levels (like "MINOR", 
> "HARMLESS" and so on...)
> 
> So it were very useful to Extend the Logger class (and 
> therefore implements
> the LoggerFactory interface and extends the Level class).
> 
> Don't you think so ??
> 
> Antoine
> 
> -----Message d'origine-----
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Envoyé : mardi 19 avril 2005 02:43
> A : log4j-user@logging.apache.org
> Cc : Log4J Users List
> Objet : Re: Extend or Wrap
> 
> 
> There is a reason to Extend.  If you want to use the forcedLog method
> to force the logging of a message without identifying it as "FATAL".
> 
> I have such a use case in a project on which I'm working.
> 
> 
> On Mar 1, 2005, at 5:18 PM, Harper, Allen ((AHARPER)) wrote:
> 
> > * Replies will be sent through Spamex to 
> log4j-user@logging.apache.org
> > * For additional info click -> http://www.spamex.com/i/?v=3D3863091
> >
> > Never mind, I may have found it.
> > Al
> >
> >
> > -----Original Message-----
> > From: Lutz Michael [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, March 01, 2005 4:13 PM
> > To: 'Log4J Users List'
> > Subject: RE: Extend or Wrap
> >
> >
> > wrap.
> >
> > Ceki is very clear about this in his book.
> >
> >
> > -----Original Message-----
> > From: Harper, Allen (AHARPER) [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, March 01, 2005 5:04 PM
> > To: Log4J Users List
> > Subject: Extend or Wrap
> >
> >
> > So, whats everone recommendations as to whether you should wrap, or
> > extend Logger?
> >
> > Whats the pros and cons?
> >
> > Al Harper
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> > 
> --------------------------------------------------------------
> ---------
> > -
> > -------
> > This message and any included attachments are from Siemens Medical
> > Solutions USA, Inc. and are intended only for the addressee(s).
> > The information contained herein may include trade secrets or
> > privileged
> > or otherwise confidential information.  Unauthorized review,
> > forwarding,
> > printing, copying, distributing, or using such information 
> is strictly
> > prohibited and may be unlawful.  If you received this 
> message in error,
> > or have reason to believe you are not authorized to receive 
> it, please
> > promptly delete this message and notify the sender by e-mail with a
> > copy
> > to [EMAIL PROTECTED]
> >
> > Thank you
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.17 - Release Date: 19/04/2005
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.17 - Release Date: 19/04/2005
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --------------------------------------------------------------
> --------------
> ---
> This message and any included attachments are from Siemens 
> Medical Solutions
> USA, Inc. and are intended only for the addressee(s).  The information
> contained herein may include trade secrets or privileged or otherwise
> confidential information.  Unauthorized review, forwarding, printing,
> copying, distributing, or using such information is strictly 
> prohibited and
> may be unlawful.  If you received this message in error, or 
> have reason to
> believe you are not authorized to receive it, please promptly 
> delete this
> message and notify the sender by e-mail with a copy to
> [EMAIL PROTECTED]
> Thank you
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.17 - Release Date: 19/04/2005
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.17 - Release Date: 19/04/2005
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to