mirror of
https://github.com/bitwarden/server.git
synced 2025-05-28 23:04:50 -05:00

* 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 <>
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Events;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
Host
|
|
.CreateDefaultBuilder(args)
|
|
.ConfigureCustomAppConfiguration(args)
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
{
|
|
webBuilder.UseStartup<Startup>();
|
|
webBuilder.ConfigureLogging((hostingContext, logging) =>
|
|
logging.AddSerilog(hostingContext, (e, globalSettings) =>
|
|
{
|
|
var context = e.Properties["SourceContext"].ToString();
|
|
if (context.Contains("IdentityServer4.Validation.TokenValidator") ||
|
|
context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
|
|
{
|
|
return e.Level >= globalSettings.MinLogLevel.EventsSettings.IdentityToken;
|
|
}
|
|
|
|
if (e.Properties.ContainsKey("RequestPath") &&
|
|
!string.IsNullOrWhiteSpace(e.Properties["RequestPath"]?.ToString()) &&
|
|
(context.Contains(".Server.Kestrel") || context.Contains(".Core.IISHttpServer")))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return e.Level >= globalSettings.MinLogLevel.EventsSettings.Default;
|
|
}));
|
|
})
|
|
.Build()
|
|
.Run();
|
|
}
|
|
}
|