C# Serilog在应用程序启动时始终停留在
我将Serilog实现到我的AspNetCore 3.1 Web API中。我的第一个想法是登录到Mssql。但当我将代码写入正确的位置时,应用程序不会启动 我的启动文件是:C# Serilog在应用程序启动时始终停留在,c#,.net-core,serilog,C#,.net Core,Serilog,我将Serilog实现到我的AspNetCore 3.1 Web API中。我的第一个想法是登录到Mssql。但当我将代码写入正确的位置时,应用程序不会启动 我的启动文件是: public class Program { public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .Wr
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.WriteTo.Seq("http://localhost:5341").CreateLogger();
try
{
Log.Information("Host starting...");
Serilog.Debugging.SelfLog.Enable(msg =>
{
Debug.Print(msg);
Debugger.Break();
});
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
哪里出错了?您没有在
useserlog
中设置任何记录器配置。您可能想从这里开始。@pinkfloydx33哪种配置?我在创建日志对象时已经配置好了。我错了吗?试试这个:useserlog((ctx,log)=>log.WriteTo.Seq(“url”)
。默认情况下,它将覆盖全局记录器以及已删除的日志。Logger=new LoggerConfiguration().WriteTo.Seq(“并使用您的评论。但没有工作……为什么,为什么不开始?我会发疯的……您没有在useserlog
中设置任何记录器配置。您可能想从那里开始。@pinkfloydx33哪个配置?我在创建日志对象时已经配置了。我错了吗?试试这个:useserlog((ctx,Log)=>Log.WriteTo.Seq(“url”))
。默认情况下,它将覆盖全局记录器以及删除的Log.Logger=new LoggerConfiguration().WriteTo.Seq(“;并使用您的注释。但是没有工作…为什么,为什么不开始?我要发疯了。。。
Loaded '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.1.4/System.Runtime.Numerics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.