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