mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
Add logging to tokenables (#2298)
* Add logging to token usages * Add settings manipulation of log levels * Maintain no logging for dev * Log exception causing Token failure in TryUnprotect * dotnet format 🤖 * Added deconstruction operator on new debug logs. * Split off log level settings into separate files * Improve log messages * dotnet format 🤖 * Fix token serialization * Final review notes Co-authored-by: Todd Martin <>
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
using AspNetCoreRateLimit;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Api;
|
||||
|
||||
@ -16,7 +15,7 @@ public class Program
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
webBuilder.ConfigureLogging((hostingContext, logging) =>
|
||||
logging.AddSerilog(hostingContext, e =>
|
||||
logging.AddSerilog(hostingContext, (e, globalSettings) =>
|
||||
{
|
||||
var context = e.Properties["SourceContext"].ToString();
|
||||
if (e.Exception != null &&
|
||||
@ -26,19 +25,19 @@ public class Program
|
||||
return false;
|
||||
}
|
||||
|
||||
if (e.Level == LogEventLevel.Information &&
|
||||
if (
|
||||
context.Contains(typeof(IpRateLimitMiddleware).FullName))
|
||||
{
|
||||
return true;
|
||||
return e.Level >= globalSettings.MinLogLevel.ApiSettings.IpRateLimit;
|
||||
}
|
||||
|
||||
if (context.Contains("IdentityServer4.Validation.TokenValidator") ||
|
||||
context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
|
||||
{
|
||||
return e.Level > LogEventLevel.Error;
|
||||
return e.Level >= globalSettings.MinLogLevel.ApiSettings.IdentityToken;
|
||||
}
|
||||
|
||||
return e.Level >= LogEventLevel.Error;
|
||||
return e.Level >= globalSettings.MinLogLevel.ApiSettings.Default;
|
||||
}));
|
||||
})
|
||||
.Build()
|
||||
|
Reference in New Issue
Block a user