mirror of
https://github.com/bitwarden/server.git
synced 2024-11-28 13:15:12 +01:00
Added loggr logging for production environment.
This commit is contained in:
parent
fea34e2826
commit
ef3853d507
@ -16,6 +16,7 @@ using Bit.Core.Identity;
|
|||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
using Repos = Bit.Core.Repositories.SqlServer;
|
using Repos = Bit.Core.Repositories.SqlServer;
|
||||||
|
using Loggr.Extensions.Logging;
|
||||||
|
|
||||||
namespace Bit.Api
|
namespace Bit.Api
|
||||||
{
|
{
|
||||||
@ -131,12 +132,24 @@ namespace Bit.Api
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
public void Configure(
|
||||||
|
IApplicationBuilder app,
|
||||||
|
IHostingEnvironment env,
|
||||||
|
ILoggerFactory loggerFactory,
|
||||||
|
GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
loggerFactory.MinimumLevel = LogLevel.Information;
|
loggerFactory.MinimumLevel = LogLevel.Information;
|
||||||
loggerFactory.AddConsole();
|
loggerFactory.AddConsole();
|
||||||
loggerFactory.AddDebug();
|
loggerFactory.AddDebug();
|
||||||
|
|
||||||
|
if(!env.IsDevelopment())
|
||||||
|
{
|
||||||
|
loggerFactory.AddLoggr(
|
||||||
|
LogLevel.Error,
|
||||||
|
globalSettings.Loggr.LogKey,
|
||||||
|
globalSettings.Loggr.ApiKey);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the platform handler to the request pipeline.
|
// Add the platform handler to the request pipeline.
|
||||||
app.UseIISPlatformHandler();
|
app.UseIISPlatformHandler();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using Microsoft.AspNet.Hosting;
|
|||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.AspNet.Mvc.Filters;
|
using Microsoft.AspNet.Mvc.Filters;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Bit.Api.Utilities
|
namespace Bit.Api.Utilities
|
||||||
{
|
{
|
||||||
@ -47,6 +48,9 @@ namespace Bit.Api.Utilities
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var logger = context.HttpContext.ApplicationServices.GetRequiredService<ILogger<ExceptionHandlerFilterAttribute>>();
|
||||||
|
logger.LogError(exception.Message, exception);
|
||||||
|
|
||||||
errorModel.Message = "An unhandled server error has occured.";
|
errorModel.Message = "An unhandled server error has occured.";
|
||||||
context.HttpContext.Response.StatusCode = 500;
|
context.HttpContext.Response.StatusCode = 500;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
|
||||||
"Microsoft.AspNet.Cors": "6.0.0-rc1-final",
|
"Microsoft.AspNet.Cors": "6.0.0-rc1-final",
|
||||||
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
|
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
|
||||||
"NewRelic.Azure.WebSites": "5.13.30"
|
"NewRelic.Azure.WebSites": "5.13.30",
|
||||||
|
"Loggr.Extensions.Logging": "1.0.1-rc1-final"
|
||||||
},
|
},
|
||||||
|
|
||||||
"commands": {
|
"commands": {
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
"mail": {
|
"mail": {
|
||||||
"apiKey": "SECRET",
|
"apiKey": "SECRET",
|
||||||
"replyToEmail": "do-not-reply@bitwarden.com"
|
"replyToEmail": "do-not-reply@bitwarden.com"
|
||||||
|
},
|
||||||
|
"loggr": {
|
||||||
|
"logKey": "SECRET",
|
||||||
|
"apiKey": "SECRET"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ namespace Bit.Core
|
|||||||
public virtual DocumentDBSettings DocumentDB { get; set; } = new DocumentDBSettings();
|
public virtual DocumentDBSettings DocumentDB { get; set; } = new DocumentDBSettings();
|
||||||
public virtual SqlServerSettings SqlServer { get; set; } = new SqlServerSettings();
|
public virtual SqlServerSettings SqlServer { get; set; } = new SqlServerSettings();
|
||||||
public virtual MailSettings Mail { get; set; } = new MailSettings();
|
public virtual MailSettings Mail { get; set; } = new MailSettings();
|
||||||
|
public virtual LoggrSettings Loggr { get; set; } = new LoggrSettings();
|
||||||
|
|
||||||
public class DocumentDBSettings
|
public class DocumentDBSettings
|
||||||
{
|
{
|
||||||
@ -27,8 +28,14 @@ namespace Bit.Core
|
|||||||
|
|
||||||
public class MailSettings
|
public class MailSettings
|
||||||
{
|
{
|
||||||
public string APIKey { get; set; }
|
public string ApiKey { get; set; }
|
||||||
public string ReplyToEmail { get; set; }
|
public string ReplyToEmail { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LoggrSettings
|
||||||
|
{
|
||||||
|
public string LogKey { get; set; }
|
||||||
|
public string ApiKey { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ namespace Bit.Core.Services
|
|||||||
public MailService(GlobalSettings globalSettings)
|
public MailService(GlobalSettings globalSettings)
|
||||||
{
|
{
|
||||||
_globalSettings = globalSettings;
|
_globalSettings = globalSettings;
|
||||||
_web = new Web(_globalSettings.Mail.APIKey);
|
_web = new Web(_globalSettings.Mail.ApiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SendAlreadyRegisteredEmailAsync(string registrantEmailAddress)
|
public async Task SendAlreadyRegisteredEmailAsync(string registrantEmailAddress)
|
||||||
|
Loading…
Reference in New Issue
Block a user