mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
update to net core 2.2
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<RootNamespace>Bit.Core</RootNamespace>
|
||||
<GenerateUserSecretsAttribute>false</GenerateUserSecretsAttribute>
|
||||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
|
||||
@ -26,20 +26,21 @@
|
||||
<PackageReference Include="Handlebars.Net" Version="1.10.1" />
|
||||
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.7.0" />
|
||||
<PackageReference Include="MailKit" Version="2.1.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.3" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="3.4.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.1.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.2.0" />
|
||||
<PackageReference Include="NBitpayClient" Version="1.0.0.34" />
|
||||
<PackageReference Include="Npgsql" Version="4.0.6" />
|
||||
<PackageReference Include="Quartz" Version="3.0.7" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.4" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.AzureDocumentDB" Version="3.8.0" />
|
||||
@ -55,7 +56,7 @@
|
||||
<PackageReference Include="U2F.Core" Version="1.0.4" />
|
||||
<PackageReference Include="Otp.NET" Version="1.2.1" />
|
||||
<PackageReference Include="YubicoDotNetClient" Version="1.2.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.6.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
@ -9,17 +10,32 @@ namespace Bit.Core.Utilities
|
||||
{
|
||||
public static class LoggerFactoryExtensions
|
||||
{
|
||||
public static ILoggerFactory AddSerilog(
|
||||
this ILoggerFactory factory,
|
||||
IApplicationBuilder appBuilder,
|
||||
public static void UseSerilog(
|
||||
this IApplicationBuilder appBuilder,
|
||||
IHostingEnvironment env,
|
||||
IApplicationLifetime appLifetime,
|
||||
GlobalSettings globalSettings,
|
||||
Func<LogEvent, bool> filter = null)
|
||||
IApplicationLifetime applicationLifetime,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
if(env.IsDevelopment())
|
||||
{
|
||||
return factory;
|
||||
return;
|
||||
}
|
||||
|
||||
if(CoreHelpers.SettingHasValue(globalSettings?.Sentry.Dsn))
|
||||
{
|
||||
appBuilder.AddSentryContext();
|
||||
}
|
||||
applicationLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
|
||||
}
|
||||
|
||||
public static ILoggingBuilder AddSerilog(
|
||||
this ILoggingBuilder builder,
|
||||
WebHostBuilderContext context,
|
||||
Func<LogEvent, bool> filter = null)
|
||||
{
|
||||
if(context.HostingEnvironment.IsDevelopment())
|
||||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
bool inclusionPredicate(LogEvent e)
|
||||
@ -36,6 +52,9 @@ namespace Bit.Core.Utilities
|
||||
return filter(e);
|
||||
}
|
||||
|
||||
var globalSettings = new GlobalSettings();
|
||||
ConfigurationBinder.Bind(context.Configuration.GetSection("GlobalSettings"), globalSettings);
|
||||
|
||||
var config = new LoggerConfiguration()
|
||||
.Enrich.FromLogContext()
|
||||
.Filter.ByIncludingOnly(inclusionPredicate);
|
||||
@ -55,8 +74,6 @@ namespace Bit.Core.Utilities
|
||||
.Enrich.WithProperty("Project", globalSettings.ProjectName)
|
||||
.Destructure.With<HttpContextDestructingPolicy>()
|
||||
.Filter.ByExcluding(e => e.Exception?.CheckIfCaptured() == true);
|
||||
|
||||
appBuilder.AddSentryContext();
|
||||
}
|
||||
else if(CoreHelpers.SettingHasValue(globalSettings.LogDirectory))
|
||||
{
|
||||
@ -66,10 +83,9 @@ namespace Bit.Core.Utilities
|
||||
}
|
||||
|
||||
var serilog = config.CreateLogger();
|
||||
factory.AddSerilog(serilog);
|
||||
appLifetime.ApplicationStopped.Register(Log.CloseAndFlush);
|
||||
builder.AddSerilog(serilog);
|
||||
|
||||
return factory;
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user