使用 GAC 时如何获取用于登录生产的堆栈跟踪信息
我想获取堆栈跟踪(文件名和行号)信息,以在生产环境中记录异常等。 DLL 安装在 GAC 中。 有什么办法可以做到这一点吗?
本文介绍了如何将 PDB 文件放入 GAC 中:
您可以轻松发现这些,因为它们会说您需要将调试符号(.pdb 文件)复制到 GAC。 就其本身而言,这是行不通的。
我知道这篇文章涉及使用 VS 进行调试,但我认为它也可能适用于记录堆栈跟踪。
我已按照此问题的说明进行操作,除了取消选中优化代码(他们说这是可选的)。
我将 dll 和 pdb 复制到 GAC 中,但仍然没有获取堆栈跟踪信息。 以下是我在堆栈跟踪的日志文件中得到的内容:
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
我正在使用 NLog。
我的 NLog 布局是:
layout="${date:format=s}|${level}|${callsite}|${identity}|${message}|${stacktrace:format=Raw}"
${stacktrace:format=Raw} 是相关部分。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用小写的 raw:
如果这不起作用,请尝试:
Try raw in lowercase:
If that doesn't work try:
试试这个:
字符串 stackTrace 将包含当前线程的 stackstrace
Try this:
The string stackTrace will have the stackstrace of the current thread