About CustomLogHandler

Nov 17, 2009 at 2:39 PM

Unable to go inside customlogHandler..................

 

 

 

 

 

 

Below is my Config File

<

<

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

handlers>add logBehavior="BeforeAndAfter" beforeMessage="" afterMessage=""

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

eventId="0" includeParameterValues="true" includeCallStack="false"

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

includeCallTime="true" priority="-1" severity="Information"

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

order="0" type="Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers.LogCallHandler, Microsoft.Practices.EnterpriseLibrary.PolicyInjection.CallHandlers, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

 

<

<

</

</

<

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

name="Logging Handler">categories>add name="Category" />categories>add>add order="1" type="NU.Dgi.ActivityTracking.ActivityLogHandler, NU.Dgi.ActivityTracking, Version=1.0.0.0, PublicKeyToken=null"

 

</

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font><font size="2" color="#0000ff">

 

</font>

 

name="Custom Handler" />handlers>

 

 

 My application is not calling CustomLogHandler

  [ConfigurationElementType(typeof(LogCallHandlerData))]
    public class ActivityLogHandler : Microsoft.Practices.Unity.InterceptionExtension.ICallHandler
    {
        #region ICallHandler Members

        public int Order { get; set; }
        public Microsoft.Practices.Unity.InterceptionExtension.IMethodReturn Invoke(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input,
            Microsoft.Practices.Unity.InterceptionExtension.GetNextHandlerDelegate getNext)
        {

           
            return getNext()(input, getNext);
        }

 

Please help me how to call this customloghandler...........

Nov 18, 2009 at 6:17 AM

Hi,

Can you try this code snippet.

 

    [ConfigurationElementType(typeof(CustomCallHandlerData))]
    public class MyCustomLogHandler : ICallHandler
    {

        public MyCustomLogHandler(NameValueCollection parameters)
        { 
            
        }

        public MyCustomLogHandler()
        { }

        #region ICallHandler Members

        public Microsoft.Practices.Unity.InterceptionExtension.IMethodReturn Invoke(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Microsoft.Practices.Unity.InterceptionExtension.GetNextHandlerDelegate getNext)
        {
            Console.WriteLine("Inside custom");
            return getNext()(input, getNext);
        }

        private int order;
        public int Order
        {
            get
            {
                return order;
            }
            set
            {
                order = value;
            }
        }

        #endregion
    }
This works for me.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com