1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-25 12:45:18 +01:00

cleanup startup logging

This commit is contained in:
Kyle Spearrin 2017-10-23 09:11:25 -04:00
parent 21f614bb2e
commit 5069814c4f
5 changed files with 40 additions and 46 deletions

View File

@ -149,28 +149,27 @@ namespace Bit.Api
IApplicationLifetime appLifetime,
GlobalSettings globalSettings)
{
loggerFactory
.AddSerilog(env, appLifetime, globalSettings, (e) =>
loggerFactory.AddSerilog(env, appLifetime, globalSettings, (e) =>
{
var context = e.Properties["SourceContext"].ToString();
if(e.Exception != null && (e.Exception.GetType() == typeof(SecurityTokenValidationException) ||
e.Exception.Message == "Bad security stamp."))
{
var context = e.Properties["SourceContext"].ToString();
if(e.Exception != null && (e.Exception.GetType() == typeof(SecurityTokenValidationException) ||
e.Exception.Message == "Bad security stamp."))
{
return false;
}
return false;
}
if(context.Contains(typeof(IpRateLimitMiddleware).FullName) && e.Level == LogEventLevel.Information)
{
return true;
}
if(context.Contains(typeof(IpRateLimitMiddleware).FullName) && e.Level == LogEventLevel.Information)
{
return true;
}
if(context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
{
return e.Level > LogEventLevel.Error;
}
if(context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
{
return e.Level > LogEventLevel.Error;
}
return e.Level >= LogEventLevel.Error;
});
return e.Level >= LogEventLevel.Error;
});
// Default Middleware
app.UseDefaultMiddleware(env);

View File

@ -64,8 +64,7 @@ namespace Bit.Billing
GlobalSettings globalSettings,
ILoggerFactory loggerFactory)
{
loggerFactory
.AddSerilog(env, appLifetime, globalSettings, (e) => e.Level >= LogEventLevel.Error);
loggerFactory.AddSerilog(env, appLifetime, globalSettings, (e) => e.Level >= LogEventLevel.Error);
if(env.IsDevelopment())
{

View File

@ -46,17 +46,17 @@ namespace Bit.Icons
IHostingEnvironment env,
TelemetryConfiguration telemetry)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
try
{
telemetry.DisableTelemetry = true;
}
catch { }
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseResponseCaching();
app.UseMvc();
}

View File

@ -72,22 +72,21 @@ namespace Bit.Identity
IApplicationLifetime appLifetime,
GlobalSettings globalSettings)
{
loggerFactory
.AddSerilog(env, appLifetime, globalSettings, (e) =>
loggerFactory.AddSerilog(env, appLifetime, globalSettings, (e) =>
{
var context = e.Properties["SourceContext"].ToString();
if(context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
{
var context = e.Properties["SourceContext"].ToString();
if(context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
{
return e.Level > LogEventLevel.Error;
}
return e.Level > LogEventLevel.Error;
}
if(context.Contains(typeof(IpRateLimitMiddleware).FullName) && e.Level == LogEventLevel.Information)
{
return true;
}
if(context.Contains(typeof(IpRateLimitMiddleware).FullName) && e.Level == LogEventLevel.Information)
{
return true;
}
return e.Level >= LogEventLevel.Error;
});
return e.Level >= LogEventLevel.Error;
});
// Default Middleware
app.UseDefaultMiddleware(env);

View File

@ -1,4 +1,4 @@
using System.IO;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
namespace Bit.Mail
@ -7,14 +7,11 @@ namespace Bit.Mail
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
WebHost
.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
host.Run();
.Build()
.Run();
}
}
}