简体   繁体   English

c#log4net 不记录异常的行号

[英]c# log4net not logging line number of exception

In my local code base, my log file logs the exact line number where the exception took place.在我的本地代码库中,我的日志文件记录了发生异常的确切行号。 However, my boss just sent me a log file from a client, and I don't see a single line number in the log.但是,我的老板刚刚从客户端向我发送了一个日志文件,而我在日志中没有看到一个行号。 Is there a setting I am missing to log the line number for a deployed application?我是否缺少记录已部署应用程序的行号的设置?

If you want line numbers in your logged stack trace you have to deploy the matching .pdb files. 如果要在记录的堆栈跟踪中显示行号,则必须部署匹配的.pdb文件。 Even then the line numbers might not match the source code if you compiled with Optimize code enabled (recommended for prod builds). 即使这样,如果启用了Optimize code编译,行号也可能与源代码不匹配(建议用于产品构建)。

Note that as well as having a .pdb file - it must be the correct one.请注意,除了拥有.pdb文件之外,它还必须是正确的。 If it's a stale/old version of the file, the framework detects that and falls back to quietly just not logging the line numbers.如果它是文件的陈旧/旧版本,框架会检测到并回退到不记录行号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM