#if (DEBUG) and line / line number mismatch log4net

When I use preprocessor directives like

1 #if(DEBUG)
2 // 1
3 // 2
4 #else
5 // 1
6 // 2
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.

+5
source share
2

, , .

, () Debugger.IsAttached , (, ) , . ,.pdb .

, , . , . !

+2

, , . , .

0

All Articles