When I use preprocessor directives like
1 #if(DEBUG)
2
3
4 #else
5
6
7 #endif
8
9 logger.Debug("Log exception, etc.");
this leads to the fact that during execution the line numbers in the log (for example, stack trace) are incorrect - in the above example, line 9 will become 4, because the rest will be analyzed by the preprocessor.
This makes log analysis difficult.
Is there a way to solve this problem without creating methods with ConditionalAttribute?
I know Debugger.IsAttached(and now I use this solution), but I would prefer to run the code based on the build mode (debug / release), and not on whether the debugger is connected.
source
share