public class Startup
{
public IConfiguration Configuration { get; private set; }
public IHostingEnvironment HostingEnvironment { get; private set; }
// Injects IHostingEnvironment and IConfiguration into the constructor. Configuration is set in Program
public Startup(IHostingEnvironment env, IConfiguration config)
{
HostingEnvironment = env;
Configuration = config;
}
public void ConfigureServices(IServiceCollection services){services. AddMvc ();// The second configuration can also include logging, AddLogging(builder => //{// Builder. AddConfiguration (Configuration. GetSection (" Logging ")) / /. AddConsole (); / /});}/ / injection ILoggerFactory
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if(env.IsDevelopment()) { app.UseDeveloperExceptionPage(); }// The third configuration injects ILogggerFactory and then configures the parameters
// Add console output
loggerFactory.AddConsole(Configuration.GetSection("Logging"));// Add debugging outputloggerFactory.AddDebug(); app.UseMvc(); }}Copy the code