continuity/Server/Program.cs

25 lines
No EOL
895 B
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using ReInject;
var services = Injector.GetContainer();
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
services.Register<IConfiguration>(DependencyStrategy.AtomicInstance, true, configuration);
ILoggerFactory loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddSimpleConsole(options =>
{
options.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Enabled;
options.TimestampFormat = "[HH:mm:ss]";
});
builder.AddFile("Logs/log-{0:yyyy}-{0:MM}-{0:dd}.txt",
opts => opts.FormatLogFileName = fileName => String.Format(fileName, DateTime.UtcNow));
});
services.Register<ILoggerFactory>(DependencyStrategy.AtomicInstance, true, loggerFactory);
var authServer = services.GetInstance<Server.AuthorizationServer>();
authServer.Start();