Skip to content
Loading
Routing settings for Areas in ASP.NET Core
  • you said ; loggerFactory.AddConsole() add log output when we run our app from the command line
     
    can we run asp.net web application from command line tool if we develop web application with VS2015 or VS2017 ?

    env.IsDevelopment() will help us to determine that code is running from IDE or exe/dll ?
  • Shashangka Shekhar

    Configuration.GetSection("Logging") access the appsettings values
    go to appsetting > Logging

    1. {  
    2.   "Logging": {  
    3.     "IncludeScopes": false,  
    4.     "LogLevel": {  
    5.       "Default": "Trace",  
    6.       "System": "Information",  
    7.       "Microsoft": "Information"  
    8.     }  
    9.   }  
    10. }  

    loggerFactory.AddConsole() add log output when we run our app from the command line

    loggerFactory.AddDebug() add log output when we run in Visual Studio in Debug mode, go to Output window in Visual Studio.

    we can access the log, here's how:
    https://stackify.com/net-core-loggerfactory-use-correctly/
    http://www.c-sharpcorner.com/article/working-with-built-in-logging-framework-in-asp-net-core/

    env.IsDevelopment() is for managing the exception if happen in development or production environment
    get more about working with multiple environment: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments

    app.UseStaticFiles() is for serving the static files from /wwwroot like html, css, js
    get more details: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/static-files

  • i have few questions.

    1) what this line of code will do Configuration.GetSection("Logging") ?

    2) loggerFactory.AddConsole() what this line will do ?

    does it add error message to console window ? if yes then when we run web application from IDE then how console window will come?

    3) loggerFactory.AddDebug(); what does it mean ?

    4) tell me rest of each line in details like what each line will do ?

    if (env.IsDevelopment())
    {
    app.UseDeveloperExceptionPage();
    app.UseBrowserLink();
    }
    else
    {
    app.UseExceptionHandler("/Home/Error");
    }

    app.UseStaticFiles();

    thanks