How to get stack trace information for logging in production when using the GAC
- by Jonathan Parker
I would like to get stack trace (file name and line number) information for logging exceptions etc. in a production environment. The DLLs are installed in the GAC. Is there any way to do this?
This article says about putting PDB files in the GAC:
You can spot these easily because they will say you need to copy the debug symbols (.pdb file) to the GAC. In and of itself, that will not work.
I know this article refers to debugging with VS but I thought it might apply to logging the stacktrace also.
I've followed the instructions for the answer to this question except for unchecking Optimize code which they said was optional.
I copied the dlls and pdbs into the GAC but I'm still not getting the stack trace information. Here's what I get in the log file for the stack trace:
OnAuthenticate at offset 161 in file:line:column <filename unknown>:0:0
ValidateUser at offset 427 in file:line:column <filename unknown>:0:0
LogException at offset 218 in file:line:column <filename unknown>:0:0
I'm using NLog.
My NLog layout is:
layout="${date:format=s}|${level}|${callsite}|${identity}|${message}|${stacktrace:format=Raw}"
${stacktrace:format=Raw} being the relevant part.