Stack trace is not enabled when a .net assembly is deployed in release mode. So we cannot get the stack trace from an exception and log it in production environment.
For knowing where an exception occurred in the production code and log it, we use a weird approach which I am not comfortable with but I cannot come up with a better solution which logs the exact method where the exception occurred in the first place.
Please note that the logging mechanism is also used for determining bugs. So when an NullReferenceException or IndexOutOfBoundsException is raised, it is not helpful to get the exception type and message only, we often need to know where exactly the exception occurred.
How do you deal with this? What information do you log on your production code when an exception occurs and how do you determine what the problem is by that information?