Setup DI and Logging
This commit is contained in:
parent
864ed2ceb1
commit
9f78185e15
1 changed files with 24 additions and 2 deletions
|
@ -1,3 +1,25 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReInject;
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
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();
|
Loading…
Reference in a new issue