Pregunta

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.

¿Fue útil?

Solución

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;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top