2020-01-10 08:33:13 -05:00
|
|
|
|
using Bit.Core.Utilities;
|
2019-07-23 16:38:49 -04:00
|
|
|
|
using Serilog.Events;
|
2018-08-02 12:14:33 -04:00
|
|
|
|
|
2018-08-16 13:45:31 -04:00
|
|
|
|
namespace Bit.Notifications;
|
2022-08-29 14:53:16 -04:00
|
|
|
|
|
2018-08-16 13:45:31 -04:00
|
|
|
|
public class Program
|
2018-08-02 12:14:33 -04:00
|
|
|
|
{
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2020-01-10 08:33:13 -05:00
|
|
|
|
Host
|
2018-08-02 12:14:33 -04:00
|
|
|
|
.CreateDefaultBuilder(args)
|
2021-04-09 09:48:43 -04:00
|
|
|
|
.ConfigureCustomAppConfiguration(args)
|
2020-01-10 08:33:13 -05:00
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
webBuilder.UseStartup<Startup>();
|
|
|
|
|
|
webBuilder.ConfigureLogging((hostingContext, logging) =>
|
|
|
|
|
|
logging.AddSerilog(hostingContext, e =>
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2020-01-10 08:33:13 -05:00
|
|
|
|
var context = e.Properties["SourceContext"].ToString();
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (context.Contains("IdentityServer4.Validation.TokenValidator") ||
|
2020-01-10 08:33:13 -05:00
|
|
|
|
context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
|
2019-07-23 16:38:49 -04:00
|
|
|
|
{
|
2020-01-10 08:33:13 -05:00
|
|
|
|
return e.Level > LogEventLevel.Error;
|
|
|
|
|
|
}
|
2019-07-23 16:38:49 -04:00
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (e.Level == LogEventLevel.Error &&
|
2020-01-10 08:33:13 -05:00
|
|
|
|
e.MessageTemplate.Text == "Failed connection handshake.")
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-07-23 16:38:49 -04:00
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (e.Level == LogEventLevel.Error &&
|
2020-01-10 08:33:13 -05:00
|
|
|
|
e.MessageTemplate.Text.StartsWith("Failed writing message."))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-08-31 08:22:30 -04:00
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (e.Level == LogEventLevel.Warning &&
|
2020-01-10 08:33:13 -05:00
|
|
|
|
e.MessageTemplate.Text.StartsWith("Heartbeat took longer"))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2019-07-23 16:38:49 -04:00
|
|
|
|
|
2020-01-10 08:33:13 -05:00
|
|
|
|
return e.Level >= LogEventLevel.Warning;
|
|
|
|
|
|
}));
|
|
|
|
|
|
})
|
2018-08-02 12:14:33 -04:00
|
|
|
|
.Build()
|
|
|
|
|
|
.Run();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|