C# 堆栈跟踪不';我没有行号
我在一个本地服务结构群集(1个节点)上运行一种应用类型下的几个不同应用。有些是无状态的,有些是有状态的。日志记录是使用Serilog完成的。问题是,所有记录的堆栈跟踪从来没有行号 部署是通过使用“调试”配置通过VisualStudio发布SF项目来完成的。我检查了SfDevCluster文件夹,可执行文件的PDB在那里 我错过什么了吗 编辑:日志设置C# 堆栈跟踪不';我没有行号,c#,azure-service-fabric,C#,Azure Service Fabric,我在一个本地服务结构群集(1个节点)上运行一种应用类型下的几个不同应用。有些是无状态的,有些是有状态的。日志记录是使用Serilog完成的。问题是,所有记录的堆栈跟踪从来没有行号 部署是通过使用“调试”配置通过VisualStudio发布SF项目来完成的。我检查了SfDevCluster文件夹,可执行文件的PDB在那里 我错过什么了吗 编辑:日志设置 public static LoggerConfiguration CreateBaseLogConfiguration(bool writeTo
public static LoggerConfiguration CreateBaseLogConfiguration(bool writeToConsole = true)
{
const string outputTemplate =
"[{Timestamp:HH:mm:ss} {Level} {RequestId}] {Message}{NewLine}{Exception}";
var config = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information);
if (writeToConsole)
config.WriteTo.Console(outputTemplate: outputTemplate);
return config;
}
var mainLoggerConfiguration = AddOutOfProcessLogging(CreateBaseLogConfiguration(true)
.Enrich.FromLogContext()
.Enrich.WithProperty("Service", "MyService")
.Enrich.WithProperty("Source", "Api"), shouldUseSeq);
Log.Logger = mainLoggerConfiguration.CreateLogger();
public static LoggerConfiguration AddOutOfProcessLogging(LoggerConfiguration loggerConfiguration, bool useSeq)
{
if (useSeq)
{
var seqServer = "http://localhost:5341";
return loggerConfiguration
.WriteTo.Seq(seqServer,
period: TimeSpan.FromMilliseconds(500),
compact: true);
}
else
{
var sumoConfig = new FabricConfigurationProvider("Logging");
var sumoLogicUrl = sumoConfig.GetValue("SumologicUrl");
var sourceCategory = sumoConfig.GetValue("SumoSourceCategory");
return loggerConfiguration
.WriteTo.SumoLogic(sumoLogicUrl, sourceName: "Serilog", sourceCategory: sourceCategory, textFormatter: new RenderedCompactJsonFormatter());
}
}
Seq和SumoLogic在记录的堆栈记录道中都没有行号
日志中的异常:
"@x": "System.Exception: Correlation failed.
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.<HandleRequestAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at React.AspNet.BabelFileMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()",
"SourceContext": "Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware",
“@x”:“System.Exception:关联失败。
在Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.d_u12.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d_u6.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在React.AspNet.BabelFileMiddleware.d_u5.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d_u6.MoveNext()中,
“SourceContext”:“Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware”,
在控制器的方法中添加的异常:
System.ArgumentException: For testing purposes.
at MyProject.Controllers.MyController.<Import>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
System.ArgumentException:用于测试目的。
在MyProject.Controllers.MyController.d_u1.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d_u12.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d_u10.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
位于Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext上下文)
位于Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(状态和下一步、范围和范围、对象和状态、布尔值和isCompleted)
在Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d_u14.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d_u22.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
位于Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext)
在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State&Next、Scope&Scope、Object&State、Boolean&isCompleted)
在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d_u17.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d_u15.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Builder.RouterMiddleware.d_u4.MoveNext()上
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.d_u6.MoveNext()中
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()中
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()上
从Visual studio运行应用程序时是否正确生成日志?您需要共享日志配置以及如何登录代码。你也可以分享没有行号的日志吗?@ChetanRanpariya谢谢你的时间,我用要求的细节更新了我的问题。我不从VS运行应用程序,因为我将调试附加到SF生成的进程。应用程序运行良好,只是记录的异常从来没有行号。我已经使用serilog很久了,以前从未遇到过这样的问题(或者任何日志记录程序),所以我怀疑这与SF有关。看起来这个异常甚至在