line numbers are disappear on production in the NL

2019-02-28 21:35发布

问题:

I configured NLog layout for having method name and line number by using ${callsite} parameters and it works well locally as below.

Application_Start(Global.asax.cs:33)

But it is changing to Application_Start without line numbers on production. I guess that it is because of it can not access line numbers without .pdb files but i am using .NET 4.5 that makes possible to access line numbers via caller attributes without .pdb files. And i understand NLog haven't optimized itself for .NET 4.5.

Is there a way to put line numbers on production for .NET 4.5 with NLog ?

回答1:

NLog does not use the new attributes in .NET 4.5

It uses the StackTrace class.

This is evident from the source code.

As such, you need the .pdb files for the line numbers.



标签: c# .net-4.5 nlog