Browse Source

LogFilePath setting

pull/2/head
Kyle Spearrin 4 years ago
parent
commit
48d14e7e39
  1. 1
      src/CryptoAgent/CryptoAgentSettings.cs
  2. 14
      src/CryptoAgent/Program.cs
  3. 7
      src/CryptoAgent/appsettings.Development.json
  4. 1
      src/CryptoAgent/appsettings.json

1
src/CryptoAgent/CryptoAgentSettings.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
{
public class CryptoAgentSettings
{
public string LogFilePath { get; set; }
public string IdentityServerUri { get; set; }
public DatabaseSettings Database { get; set; }

14
src/CryptoAgent/Program.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Serilog;
@ -15,11 +16,18 @@ namespace Bit.CryptoAgent @@ -15,11 +16,18 @@ namespace Bit.CryptoAgent
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureLogging((hostingContext, logging) =>
{
var settings = new CryptoAgentSettings();
ConfigurationBinder.Bind(
hostingContext.Configuration.GetSection("CryptoAgentSettings"), settings);
var serilogConfig = new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File("/etc/bitwarden/logs/log.txt",
rollOnFileSizeLimit: true,
.Enrich.FromLogContext();
if (!string.IsNullOrWhiteSpace(settings.LogFilePath))
{
serilogConfig.WriteTo.File(settings.LogFilePath, rollOnFileSizeLimit: true,
rollingInterval: RollingInterval.Day);
}
var serilog = serilogConfig.CreateLogger();
logging.AddSerilog(serilog);

7
src/CryptoAgent/appsettings.Development.json

@ -1,12 +1,11 @@ @@ -1,12 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
"Default": "Information"
}
},
"cryptoAgentSettings": {
"identityServerUri": "http://localhost:33656/"
"identityServerUri": "http://localhost:33656/",
"logFilePath": null
}
}

1
src/CryptoAgent/appsettings.json

@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
},
"AllowedHosts": "*",
"cryptoAgentSettings": {
"logFilePath": "/etc/bitwarden/logs/log.txt",
"identityServerUri": "https://identity.bitwarden.com/",
"database": {
"provider": "json",

Loading…
Cancel
Save