[prev in list] [next in list] [prev in thread] [next in thread] 

List:       avalon-dev
Subject:    Re: Fwd: %{method} LogKit pattern with Excaliburs LogKitLoggerManager
From:       "Shash Chatterjee" <shash_list () hotmail ! com>
Date:       2002-10-31 4:30:54
[Download RAW message or body]

Leo and Peter, thanks for the answers!

Peter,

Thanks for the suggestion, quite simple and quick.
I ended up copying and modifying Excalibur Logger's FormatFactory
so has to have the "extended" type as well as my custom one.
All of this works great!

Thanks again,
Shash
----- Original Message -----
From: "Peter Donald" <peter@apache.org>
To: <avalon-dev@jakarta.apache.org>; <avalon-user@jakarta.apache.org>
Sent: Wednesday, October 30, 2002 5:31 PM
Subject: Re: Fwd: %{method} LogKit pattern with Excaliburs
LogKitLoggerManager


Hi there,

Unfortunately there is no inbuilt way to fix this at this stage. However for
an imediate fix to your problem you can write your own pattern formatter
(copy paste from ExtendedPatternFormatter if you want). Then replace
"getMethod" with changes as below (look for //PD: to see changes).

    /**
     * Utility method to format category.
     *
     * @param event the event
     * @param format ancilliary format parameter - allowed to be null
     * @return the formatted string
     */
    private String getMethod( final LogEvent event, final String format )
    {
        final ContextMap map = event.getContextMap();
        if( null != map )
        {
            final Object object = map.get( "method" );
            if( null != object )
            {
                return object.toString();
            }
        }

        //PD: Changed the next line to refer to Framework Logger class
instead
        final String result =
              StackIntrospector.getCallerMethod( LogKitLogger.class );
        if( null == result )
        {
            return "UnknownMethod";
        }
        return result;
    }

On Thu, 31 Oct 2002 02:21, Shash Chatterjee wrote:
> Hi!
>
> I posted this on the users' list a couple days back, but did not get an
> answer.  I am trying to figure out if this is a known limitation of having
> a "facade" between the end-user app and Logkit, or I am doing something
> incorrectly.
>
> Thanks,
> Shash
>
> From: "Shash Chatterjee" <shash_list@hotmail.com>
>
> >Reply-To: "Avalon framework users" <avalon-users@jakarta.apache.org>
> >To: <avalon-users@jakarta.apache.org>
> >Subject: %{method} LogKit pattern with Excaliburs LogKitLoggerManager
> >Date: Sun, 27 Oct 2002 23:52:07 -0600
> >
> >Hi!
> >
> >I am trying to use an extended logkit pattern formatter with our
> >Fortress/DefaultContainer-based container.
> >However, %{method} always resolves to
>
>"org.apache.avalon.framework.logger.LogKitLogger.debug(LogKitLogger.java:3
> >9) ".
> >
> >I can see that this is because ExtendPatternFormatter#getMethod() is
> >popping
> >up to "org.apache.log.Logger" from the call-stack, which still leaves
> >LogKitLogger on the stack above the method I am really intesrested in.
> >
> >I am getting my Logger (org.apache.avalon.framework.logger.Logger) as
> > such:
> >
> >     import org.apache.avalon.excalibur.logger.LogKitLoggerManager;
> >     import org.apache.avalon.excalibur.logger.LoggerManager;
> >     import org.apache.avalon.framework.logger.Logger;
> >
> >     private static Logger rootLogger = null;
> >     private static LoggerManager rootLoggerManager = null;
> >      ......
> >       LogKitLoggerManager tmp = new LogKitLoggerManager();
> >       try {
> >            tmp.contextualize(rootContext);
> >            tmp.configure(logkitConf);  // built from a logkit.xconf
> >      } catch .....
> >         ....
> >      }
> >      rootLoggerManager = tmp;
> >      rootLogger = rootLoggerManager.getLoggerForCategory("root");
> >      rootLogger.debug("......");
> >     .....
> >
> >So, what am I doing wrong and how can I get around this problem?
> >
> >Thanks,
> >Shash
> >
> >--
> >To unsubscribe, e-mail:
> ><mailto:avalon-users-unsubscribe@jakarta.apache.org>
> >For additional commands, e-mail:
> ><mailto:avalon-users-help@jakarta.apache.org>
>
> _________________________________________________________________
> Unlimited Internet access for only $21.95/month.  Try MSN!
> http://resourcecenter.msn.com/access/plans/2monthsfree.asp

--
Cheers,

Peter Donald
----------------------------------------
"Liberty means responsibility. That is
      why most men dread it." - Locke
----------------------------------------


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic