When I debug an application in C# and an exception happens, the Exception object contains a lot of information. For instance: the class and method that caused the exception. I log this information to a log file.
When I built/compile an application, I get very little infor开发者_JS百科mation in my log file. Something like "Property does not exist", without any information about which class, method or property caused the exception.
How can I change that?
Are you logging with ex.ToString()
or just ex.Message
? You want the former.
In addition to Steven's answer, note that stack trace information will be "truncated" if you're creating a Release build, as opposed to a Debug build. That is, Debug builds include line numbers and so forth, but Release builds won't.
精彩评论