public virtual IServiceCollection InitServiceCollection()

in src/KernelApplication.cs [564:602]


        public virtual IServiceCollection InitServiceCollection(string connectionFile, LogLevel minLevel = LogLevel.Debug)
        {
            var serviceCollection = new ServiceCollection();
            // Use a temporary logger factory so that we can report information
            // gathered during startup.
            using (var loggerFactory = new LoggerFactory())
            {
                var logger = loggerFactory.CreateLogger(this.GetType().FullName);

                serviceCollection
                    // For now, we add a logger that reports to the console.
                    // TODO: add a logger that reports back to the client.
                    .AddLogging(loggingBuilder =>
                    {
                        loggingBuilder
                            .SetMinimumLevel(minLevel)
                            .AddFilter("Microsoft", minLevel)
                            .AddFilter("System", minLevel)
                            .AddConsole();
                        configureLogging?.Invoke(loggingBuilder);
                    })
                    // We need to pass along the context to each server, including
                    // information gleaned from the connection file and from user
                    // preferences.
                    .Configure<KernelContext>(
                        ctx =>
                        {
                            ctx.LoadConnectionFile(connectionFile, logger);
                            ctx.Properties = properties;
                        }
                    )

                    // Add the Shell and Heartbeat servers:
                    .AddKernelServers();

                configure(serviceCollection);
            }
            return serviceCollection;
        }