Logging application block does not work for nested application call

Topics: General discussion, Logging Application Block, Policy Injection Application Block
Sep 7, 2008 at 6:25 PM

Hi,

I am using "Logging application block", one of my requirement is to call function from function (nested function), as shown in the following code, SimpleFunction() get call from NestedFunctionOfSomeClass() but in this scenario, SimpleFunction() is NOT logged, only NestedFunctionOfSameClass() get logged.

Is it possible using Logging application block or is there any workaroud for this?

** If I call these 2 function separately then both functions are logged.

namespace ELBlocks
{
 
    public partial class ELBlocksWithLogging : Form
    {

        /* Other part of code is commented. */

        private void btn_Function_From_Function_Click(object sender, EventArgs e)
        {
            IOrder order = PolicyInjection.Create<Order, IOrder>();
            order.NestedFunctionOfSameClass("Test sting");
        }           
    }

    public interface IOrder
    {
        [Tag("Log")]
        void NestedFunctionOfSameClass(string reason);
        [Tag("Log")]
        void SimpleFunction();
    }

    public class Order : IOrder
    {
        public void NestedFunctionOfSameClass(string reason)
        {
            MessageBox.Show("NestedFunctionOfSameClass: This will call another function directly");
            SimpleFunction();
            MessageBox.Show("NestedFunctionOfSameClass: This does not work");
        }

        public void SimpleFunction()
        {
            MessageBox.Show("SimpleFunction");
        }
       
    }
  
}

Sep 9, 2008 at 1:43 PM
Hi,

Remoting-based policy injection only applies to externally called methods since it relies on proxies (and calls to this do not go through proxies); this is not limited to the logging handler.

Regards,
Fernando