Question

I would like to use Postsharp and I'm trying to figure out if it is possible to disable/enable logging with PostSharp at run-time?

In my case, I apply the aspect in the assembly of the project, and compile my project with "Disable PostSharp for this configuration" in PostSharp tab equal to No.

Thanks, Lev

Was it helpful?

Solution

PostSharp weaves in the logging aspects during build-time and you cannot remove this logging code during run-time.

The aspects usually send logging messages to the logging library of your choice (e.g. log4net, nlog). What you can do is to disable the output in that logging library during run-time.

You can find more info in the documentation of the particular logging library, for example:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top