AOP logging issues The overhead of performance for logging depends on how this is done.
I assume that you want you to enter a registration code into it. dynamic aop is only possible
- for virtual methods and
- for interfaces.
So you need compiletime aop .
I don't know how post-sharp does aop. with compiletime linfu-aop, each method gets pre-and post-execution when dynamiclally determines if and what aop aspects are executed. this trick really removes delimiters on non-virtual methods, making them pseudo-virtual.
I prefer to do manuall (= non-aop -) logging with common.logging , which uses the log4.net provider. This solution has minimal runtime if registration is disabled . Enabling / disabling logging can be done without recompiling - it is just a configuration file that can say "all datalayer actions with sql", but not "sql in the xyz module".
The expensive stacktrace analysis (which class am I logging into or for me in debug / trace, Info, ....) is performed only once for each class.
Disabled registrations can be redirected to one cheap boolen variable, plus one if. This speed to optimize size can be handled using
logger.Debug(m => m("... costly string formatting "));
syntax
which compiled into something similar to
if (logger.IsDebugEnabled) call anonymous method that does the expensive string formatting
source share