简体   繁体   English

后期日志记录未触发

[英]postsharp logging is not triggering

this is the very first time I am trying to use postsharp . 这是我第一次尝试使用postharp

I have added new class library to my solution and add postsharp using nuget manager . 我已经在解决方案中添加了新的类库 ,并使用nuget manager添加了postharp。 my concern is to refer this class library in my other projects in the solution. 我关心的是在解决方案的其他项目中引用该类库。

in my class library I hav e added new class 在班级库中,我添加了新班级

[Serializable]
    public class MethodLogAspect : OnMethodBoundaryAspect
    {
        public override void OnEntry(MethodExecutionArgs args)
        {
            Console.WriteLine("OnEntry" + args.Method.Name);          
        }

        public override void OnExit(MethodExecutionArgs args)
        {
        Console.WriteLine("OnExit" + args.Method.Name);   
        }

        public override void OnException(MethodExecutionArgs args)
        {
             Console.WriteLine("OnException" + args.Method.Name);   
        }
    }

Now I have reffer this in my another class library project in same solution. 现在,我在同一解决方案的另一个类库项目中对此进行了介绍。

[MethodLogAspect]
        public DataLayer()
        {
        .......
        }

but logins are not happening. 但没有登录。 no error can found also. 也没有发现错误。 please help me with a solution 请帮我解决

Try changing your class name like this : 尝试像这样更改您的班级名称:

[Serializable]
public class MethodLogAttribute : OnMethodBoundaryAspect
{
    // Your logging methods
}

And then in your other class methods use it like this : 然后在其他类方法中使用它,如下所示:

[MethodLog]
Public void GetData()
{
   // Your code
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM