Fix missing logs

This commit is contained in:
nicolas.dorier
2018-07-01 15:52:11 +09:00
parent b7abc08c27
commit 06b02b8691
2 changed files with 15 additions and 3 deletions

View File

@@ -14,11 +14,16 @@ namespace BTCPayServer.Logging
Configure(new FuncLoggerFactory(n => NullLogger.Instance));
}
public static void Configure(ILoggerFactory factory)
{
if (factory == null)
Configure(new FuncLoggerFactory(n => NullLogger.Instance));
else
{
Configuration = factory.CreateLogger("Configuration");
PayServer = factory.CreateLogger("PayServer");
Events = factory.CreateLogger("Events");
}
}
public static ILogger Configuration
{
get; set;

View File

@@ -31,9 +31,14 @@ namespace BTCPayServer
var logger = loggerFactory.CreateLogger("Configuration");
try
{
// This is the only way toat LoadArgs can print to console. Because LoadArgs is called by the HostBuilder before Logs.Configure is called
var conf = new DefaultConfiguration() { Logger = logger }.CreateConfiguration(args);
if (conf == null)
return;
Logs.Configure(loggerFactory);
new BTCPayServerOptions().LoadArgs(conf);
Logs.Configure(null);
/////
host = new WebHostBuilder()
.UseKestrel()
@@ -64,6 +69,8 @@ namespace BTCPayServer
finally
{
processor.Dispose();
if(host == null)
Logs.Configuration.LogError("Configuration error");
if (host != null)
host.Dispose();
loggerProvider.Dispose();