Skip to content

Commit fdfec0a

Browse files
authored
Remove deprecated logging methods (#6516)
1 parent 0422796 commit fdfec0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+88
-683
lines changed

.github/renovate.json5

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@
9090
"Microsoft.AspNetCore.Mvc.Testing",
9191
"Newtonsoft.Json",
9292
"NSubstitute",
93-
"Sentry.Serilog",
94-
"Serilog.AspNetCore",
95-
"Serilog.Extensions.Logging",
9693
"Serilog.Extensions.Logging.File",
97-
"Serilog.Sinks.SyslogMessages",
9894
"Stripe.net",
9995
"Swashbuckle.AspNetCore",
10096
"Swashbuckle.AspNetCore.SwaggerGen",

bitwarden_license/src/Scim/Program.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,8 @@ public static void Main(string[] args)
1111
.ConfigureWebHostDefaults(webBuilder =>
1212
{
1313
webBuilder.UseStartup<Startup>();
14-
webBuilder.ConfigureLogging((hostingContext, logging) =>
15-
logging.AddSerilog(hostingContext, (e, globalSettings) =>
16-
{
17-
var context = e.Properties["SourceContext"].ToString();
18-
19-
if (e.Properties.TryGetValue("RequestPath", out var requestPath) &&
20-
!string.IsNullOrWhiteSpace(requestPath?.ToString()) &&
21-
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
22-
{
23-
return false;
24-
}
25-
26-
return e.Level >= globalSettings.MinLogLevel.ScimSettings.Default;
27-
}));
2814
})
15+
.AddSerilogFileLogging()
2916
.Build()
3017
.Run();
3118
}

bitwarden_license/src/Scim/Startup.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ public void ConfigureServices(IServiceCollection services)
9494
public void Configure(
9595
IApplicationBuilder app,
9696
IWebHostEnvironment env,
97-
IHostApplicationLifetime appLifetime,
9897
GlobalSettings globalSettings)
9998
{
100-
app.UseSerilog(env, appLifetime, globalSettings);
101-
10299
// Add general security headers
103100
app.UseMiddleware<SecurityHeadersMiddleware>();
104101

bitwarden_license/src/Scim/appsettings.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
"connectionString": "SECRET",
3131
"applicationCacheTopicName": "SECRET"
3232
},
33-
"sentry": {
34-
"dsn": "SECRET"
35-
},
3633
"notificationHub": {
3734
"connectionString": "SECRET",
3835
"hubName": "SECRET"

bitwarden_license/src/Sso/Program.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Bit.Core.Utilities;
2-
using Serilog;
32

43
namespace Bit.Sso;
54

@@ -13,19 +12,8 @@ public static void Main(string[] args)
1312
.ConfigureWebHostDefaults(webBuilder =>
1413
{
1514
webBuilder.UseStartup<Startup>();
16-
webBuilder.ConfigureLogging((hostingContext, logging) =>
17-
logging.AddSerilog(hostingContext, (e, globalSettings) =>
18-
{
19-
var context = e.Properties["SourceContext"].ToString();
20-
if (e.Properties.TryGetValue("RequestPath", out var requestPath) &&
21-
!string.IsNullOrWhiteSpace(requestPath?.ToString()) &&
22-
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
23-
{
24-
return false;
25-
}
26-
return e.Level >= globalSettings.MinLogLevel.SsoSettings.Default;
27-
}));
2815
})
16+
.AddSerilogFileLogging()
2917
.Build()
3018
.Run();
3119
}

bitwarden_license/src/Sso/Startup.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ public void Configure(
100100
IdentityModelEventSource.ShowPII = true;
101101
}
102102

103-
app.UseSerilog(env, appLifetime, globalSettings);
104-
105103
// Add general security headers
106104
app.UseMiddleware<SecurityHeadersMiddleware>();
107105

src/Admin/Program.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,8 @@ public static void Main(string[] args)
1616
o.Limits.MaxRequestLineSize = 20_000;
1717
});
1818
webBuilder.UseStartup<Startup>();
19-
webBuilder.ConfigureLogging((hostingContext, logging) =>
20-
logging.AddSerilog(hostingContext, (e, globalSettings) =>
21-
{
22-
var context = e.Properties["SourceContext"].ToString();
23-
if (e.Properties.TryGetValue("RequestPath", out var requestPath) &&
24-
!string.IsNullOrWhiteSpace(requestPath?.ToString()) &&
25-
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
26-
{
27-
return false;
28-
}
29-
return e.Level >= globalSettings.MinLogLevel.AdminSettings.Default;
30-
}));
3119
})
20+
.AddSerilogFileLogging()
3221
.Build()
3322
.Run();
3423
}

src/Admin/Startup.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,8 @@ public void ConfigureServices(IServiceCollection services)
132132
public void Configure(
133133
IApplicationBuilder app,
134134
IWebHostEnvironment env,
135-
IHostApplicationLifetime appLifetime,
136135
GlobalSettings globalSettings)
137136
{
138-
app.UseSerilog(env, appLifetime, globalSettings);
139-
140137
// Add general security headers
141138
app.UseMiddleware<SecurityHeadersMiddleware>();
142139

src/Api/Program.cs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// FIXME: Update this file to be null safe and then delete the line below
2-
#nullable disable
3-
4-
using AspNetCoreRateLimit;
5-
using Bit.Core.Utilities;
6-
using Microsoft.IdentityModel.Tokens;
1+
using Bit.Core.Utilities;
72

83
namespace Bit.Api;
94

@@ -17,32 +12,8 @@ public static void Main(string[] args)
1712
.ConfigureWebHostDefaults(webBuilder =>
1813
{
1914
webBuilder.UseStartup<Startup>();
20-
webBuilder.ConfigureLogging((hostingContext, logging) =>
21-
logging.AddSerilog(hostingContext, (e, globalSettings) =>
22-
{
23-
var context = e.Properties["SourceContext"].ToString();
24-
if (e.Exception != null &&
25-
(e.Exception.GetType() == typeof(SecurityTokenValidationException) ||
26-
e.Exception.Message == "Bad security stamp."))
27-
{
28-
return false;
29-
}
30-
31-
if (
32-
context.Contains(typeof(IpRateLimitMiddleware).FullName))
33-
{
34-
return e.Level >= globalSettings.MinLogLevel.ApiSettings.IpRateLimit;
35-
}
36-
37-
if (context.Contains("Duende.IdentityServer.Validation.TokenValidator") ||
38-
context.Contains("Duende.IdentityServer.Validation.TokenRequestValidator"))
39-
{
40-
return e.Level >= globalSettings.MinLogLevel.ApiSettings.IdentityToken;
41-
}
42-
43-
return e.Level >= globalSettings.MinLogLevel.ApiSettings.Default;
44-
}));
4515
})
16+
.AddSerilogFileLogging()
4617
.Build()
4718
.Run();
4819
}

src/Api/Startup.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,10 @@ public void ConfigureServices(IServiceCollection services)
234234
public void Configure(
235235
IApplicationBuilder app,
236236
IWebHostEnvironment env,
237-
IHostApplicationLifetime appLifetime,
238237
GlobalSettings globalSettings,
239238
ILogger<Startup> logger)
240239
{
241240
IdentityModelEventSource.ShowPII = true;
242-
app.UseSerilog(env, appLifetime, globalSettings);
243241

244242
// Add general security headers
245243
app.UseMiddleware<SecurityHeadersMiddleware>();

0 commit comments

Comments
 (0)