문제

I trying to understand AOP and PostSharp and was wondering in production how can I turn on PostSharp to capture logs and equally turn it off when not required? I am hoping there is a flag in a config file that will enable me to turn on logging or turn it off.

Thanks.

도움이 되었습니까?

해결책

PostSharp builds IL at compile time and injects it. You cannot turn it off at run-time, and thus you cannot turn it off in PROD. However, you can very easily build an application setting that your PostSharp code reads and just return the default workflow when that flag is on.

At least this way you'd be able to stop any additional code from executing.

if (ConfigurationManager.AppSettings["YourSetting"] == "some_value")
{
    args.FlowBehavior = FlowBehavior.Default;
    return;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top