using Furion.Logging; // 处理未捕获的异常 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); // 启动 webServer Serve.Run(RunOptions.Default.AddWebComponent().WithArgs(args)); void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Log.Error(sender?.ToString(), e); } public class WebComponent : IWebComponent { public void Load(WebApplicationBuilder builder, ComponentContext componentContext) { // 日志过滤 builder.Logging.AddFilter((provider, category, logLevel) => { return !new[] { "Microsoft.Hosting", "Microsoft.AspNetCore" }.Any(u => category.StartsWith(u)) && logLevel >= LogLevel.Information; }); } }