From 22b863ff24a446f95222364da4e440253a27e3f5 Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 28 May 2019 10:46:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(Rollbar):=20=E5=A2=9E=E5=8A=A0=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=80=9A=E7=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Bootstrap.Admin.csproj | 1 + Bootstrap.Admin/Startup.cs | 7 +++++++ Bootstrap.Admin/appsettings.json | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Bootstrap.Admin/Bootstrap.Admin.csproj b/Bootstrap.Admin/Bootstrap.Admin.csproj index 6c1efb32..b5801c33 100644 --- a/Bootstrap.Admin/Bootstrap.Admin.csproj +++ b/Bootstrap.Admin/Bootstrap.Admin.csproj @@ -20,6 +20,7 @@ + diff --git a/Bootstrap.Admin/Startup.cs b/Bootstrap.Admin/Startup.cs index d9438495..f12359d9 100644 --- a/Bootstrap.Admin/Startup.cs +++ b/Bootstrap.Admin/Startup.cs @@ -13,8 +13,10 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Versioning; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; +using Rollbar.NetCore.AspNet; using Swashbuckle.AspNetCore.Swagger; using System; using System.IO; @@ -70,6 +72,10 @@ namespace Bootstrap.Admin services.AddSignalR().AddJsonProtocalDefault(); services.AddSignalRExceptionFilterHandler(async (client, ex) => await SignalRManager.Send(client, ex)); services.AddResponseCompression(); + services.AddRollbarLogger(loggerOptions => + { + loggerOptions.Filter = (loggerName, loglevel) => loglevel >= LogLevel.Trace; + }); services.AddMvc(options => { options.Filters.Add(); @@ -137,6 +143,7 @@ namespace Bootstrap.Admin app.UseOnlineUsers(callback: TraceHelper.Save); app.UseCacheManagerCorsHandler(); app.UseSignalR(routes => { routes.MapHub("/NotiHub"); }); + app.UseRollbarMiddleware(); app.UseMvc(routes => { routes.MapRoute( diff --git a/Bootstrap.Admin/appsettings.json b/Bootstrap.Admin/appsettings.json index cb71eb2f..8340c091 100644 --- a/Bootstrap.Admin/appsettings.json +++ b/Bootstrap.Admin/appsettings.json @@ -12,6 +12,10 @@ "FileName": "Error\\Log.log" } }, + "Rollbar": { + "AccessToken": "2fbdc15dff334a73a5542e6e82309a35", + "Environment": "AspNetCoreMiddlewareTest" + }, "ConnectionStrings": { "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa" },