0
Web APIをホストするコンソールアプリケーションがあります。今度は、すでに設定されているIServiceCollection
とILoggerFactory
をStartup
に渡したいと思います。.NETコア2で既存のIServiceCollectionとILoggerFactoryをスタートアップに渡す
var serviceCollection = new ServiceCollection();
// Do some registrations here...
var loggerFactory = new LoggerFactory(); // Actually not created this way. Just an example.
loggerFactory.AddSomeStuff();
var host = WebHost.CreateDefaultBuilder()
.UseKestrel()
.ConfigureServices(collection =>
{
// I want to use my already configured serviceCollection.
// I do not want to configure it here...
})
.ConfigureLogging((hostingContext, logging) =>
{
// I want to use my already configured ILoggerFactory.
// I do not want to configure it here...
})
.UseStartup<Startup>()
.Build();
は基本的に私は私のスタートアップで使用する私のすでにloggerFactory
とserviceCollection
を作成しました。それは可能ですか?もしそうなら、どうしたらいいですか?