mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
Add sentry logging support. (#240)
This commit is contained in:

committed by
Kyle Spearrin

parent
bf3c01ac46
commit
702d833cea
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
@ -10,6 +11,7 @@ namespace Bit.Core.Utilities
|
||||
{
|
||||
public static ILoggerFactory AddSerilog(
|
||||
this ILoggerFactory factory,
|
||||
IApplicationBuilder appBuilder,
|
||||
IHostingEnvironment env,
|
||||
IApplicationLifetime appLifetime,
|
||||
GlobalSettings globalSettings,
|
||||
@ -32,6 +34,16 @@ namespace Bit.Core.Utilities
|
||||
config.WriteTo.AzureDocumentDB(new Uri(globalSettings.DocumentDb.Uri), globalSettings.DocumentDb.Key,
|
||||
timeToLive: TimeSpan.FromDays(7));
|
||||
}
|
||||
else if(globalSettings.Sentry != null && CoreHelpers.SettingHasValue(globalSettings.Sentry.Dsn))
|
||||
{
|
||||
config.WriteTo.Sentry(globalSettings.Sentry.Dsn)
|
||||
.Enrich.FromLogContext()
|
||||
.Enrich.WithProperty("Project", globalSettings.ProjectName)
|
||||
.Destructure.With<HttpContextDestructingPolicy>()
|
||||
.Filter.ByExcluding(e => e.Exception?.CheckIfCaptured() == true);
|
||||
|
||||
appBuilder.AddSentryContext();
|
||||
}
|
||||
else if(CoreHelpers.SettingHasValue(globalSettings.LogDirectory))
|
||||
{
|
||||
config.WriteTo.RollingFile($"{globalSettings.LogDirectory}/{globalSettings.ProjectName}/{{Date}}.txt");
|
||||
|
Reference in New Issue
Block a user